Class: RuboCop::Formatter::MarkdownFormatter Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

def files
  @files
end

#summaryObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

def summary
  @summary
end

Instance Method Details

#file_finished(file, offenses) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

def started(target_files)
  summary.target_files = target_files
end