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.



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

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

Instance Method Details

#bodyObject



262
263
264
265
266
267
268
269
270
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 262

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

#categoriesObject



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

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

#descriptionObject



258
259
260
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 258

def description
  data["description"]
end

#engine_nameObject



300
301
302
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 300

def engine_name
  data["engine_name"]
end

#locationObject



279
280
281
282
283
284
285
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 279

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

#other_locationsObject



287
288
289
290
291
292
293
294
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 287

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



272
273
274
275
276
277
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 272

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