Class: CC::Analyzer::Formatters::HTMLFormatter::Issue

Inherits:
Object
  • Object
show all
Defined in:
lib/cc/analyzer/formatters/html_formatter.rb

Constant Summary collapse

MARKDOWN_CONFIG =
{ autolink: true, fenced_code_blocks: true, no_intra_emphasis: true, tables: true }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(data, filesystem) ⇒ Issue

Returns a new instance of Issue.



249
250
251
252
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 249

def initialize(data, filesystem)
  @data = data
  @filesystem = filesystem
end

Instance Method Details

#bodyObject



258
259
260
261
262
263
264
265
266
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 258

def body
  @body ||=
    begin
      text = data.fetch("content", {}).fetch("body", "").strip
      unless text.empty?
        markdown(text)
      end
    end
end

#categoriesObject



292
293
294
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 292

def categories
  data.fetch("categories", [])
end

#descriptionObject



254
255
256
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 254

def description
  data["description"]
end

#engine_nameObject



296
297
298
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 296

def engine_name
  data["engine_name"]
end

#locationObject



275
276
277
278
279
280
281
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 275

def location
  @location ||=
    Location.new(
      source.buffer,
      data["location"],
    )
end

#other_locationsObject



283
284
285
286
287
288
289
290
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 283

def other_locations
  @other_locations ||=
    begin
      data.fetch("other_locations", []).map do |loc|
        [SourceFile.new(loc["path"], filesystem), loc]
      end.to_h
    end
end

#sourceObject



268
269
270
271
272
273
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 268

def source
  @source ||= SourceFile.new(
    data.fetch("location", {}).fetch("path", ""),
    filesystem,
  )
end