Class: TodoListFormatter

Inherits:
RuboCop::Formatter::ProgressFormatter
  • Object
show all
Defined in:
lib/datarockets_style/formatter/todo_list_formatter.rb

Overview

This formatter works like default formattter (display dots for files with no offenses and letters for files with problems in the them).

In the end, it shows report with sorted cops and files which can be added to rubocop config.

Here’s the format:

Inspecting 3 files .CC 3 files inspected, 1005001 offenses detected

LineLength

Exclude:
  - "really/bad/file.rb" # 100500
  - "almost/ok.rb" # 1

Defined Under Namespace

Classes: FileOffence

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#offense_listObject (readonly)

Returns the value of attribute offense_list.



22
23
24
# File 'lib/datarockets_style/formatter/todo_list_formatter.rb', line 22

def offense_list
  @offense_list
end

Instance Method Details

#file_finished(file, offenses) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/datarockets_style/formatter/todo_list_formatter.rb', line 31

def file_finished(file, offenses)
  count_stats(offenses)
  report_file_as_mark(offenses)

  return if offenses.empty?

  path = Pathname.new(file).relative_path_from(Pathname.new(Dir.pwd))

  offenses.reject(&:corrected?).each do |offense|
    offense_list << FileOffence.new(path, offense.cop_name)
  end
end

#finished(inspected_files) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/datarockets_style/formatter/todo_list_formatter.rb', line 44

def finished(inspected_files)
  report_summary(inspected_files.length,
    @total_offense_count,
    @total_correction_count,
    @total_correctable_count)
  output.puts

  DatarocketsStyle::Formatter::TodoListFormatter::ReportSummary.new(offense_list).call(output)
end

#started(target_files) ⇒ Object



26
27
28
29
# File 'lib/datarockets_style/formatter/todo_list_formatter.rb', line 26

def started(target_files)
  super
  @offense_list = []
end