Class: RuboCop::Formatter::MarkdownFormatter

Inherits:
BaseFormatter show all
Includes:
TextUtil, PathUtil
Defined in:
lib/rubocop/formatter/markdown_formatter.rb

Overview

This formatter displays the report data in markdown

Constant Summary

Constants included from PathUtil

PathUtil::HIDDEN_FILE_PATTERN

Instance Attribute Summary collapse

Attributes inherited from BaseFormatter

#options, #output

Instance Method Summary collapse

Methods included from PathUtil

absolute?, glob?, hidden_dir?, hidden_file?, hidden_file_in_not_hidden_dir?, match_path?, maybe_hidden_file?, relative_path, smart_path

Methods included from TextUtil

pluralize

Methods inherited from BaseFormatter

#file_started

Constructor Details

#initialize(output, options = {}) ⇒ MarkdownFormatter

Returns a new instance of MarkdownFormatter.



11
12
13
14
15
# File 'lib/rubocop/formatter/markdown_formatter.rb', line 11

def initialize(output, options = {})
  super
  @files = []
  @summary = Struct.new(:offense_count, :inspected_files, :target_files).new(0)
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



9
10
11
# File 'lib/rubocop/formatter/markdown_formatter.rb', line 9

def files
  @files
end

#summaryObject (readonly)

Returns the value of attribute summary.



9
10
11
# File 'lib/rubocop/formatter/markdown_formatter.rb', line 9

def summary
  @summary
end

Instance Method Details

#file_finished(file, offenses) ⇒ Object



21
22
23
24
# File 'lib/rubocop/formatter/markdown_formatter.rb', line 21

def file_finished(file, offenses)
  files << Struct.new(:path, :offenses).new(file, offenses)
  summary.offense_count += offenses.count
end

#finished(inspected_files) ⇒ Object



26
27
28
29
# File 'lib/rubocop/formatter/markdown_formatter.rb', line 26

def finished(inspected_files)
  summary.inspected_files = inspected_files
  render_markdown
end

#started(target_files) ⇒ Object



17
18
19
# File 'lib/rubocop/formatter/markdown_formatter.rb', line 17

def started(target_files)
  summary.target_files = target_files
end