Class: RuboCop::Formatter::MaximusRuboFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- RuboCop::Formatter::MaximusRuboFormatter
- Includes:
- PathUtil
- Defined in:
- lib/maximus/reporter/rubocop.rb
Overview
This formatter formats the report data in JSON Makes it consistent with output of other Maximus linters
Instance Attribute Summary collapse
-
#output_hash ⇒ Object
readonly
Returns the value of attribute output_hash.
Instance Method Summary collapse
- #file_finished(file, offenses) ⇒ Object
- #finished(inspected_files) ⇒ Object
- #hash_for_offense(offense) ⇒ Object
-
#initialize(output) ⇒ MaximusRuboFormatter
constructor
A new instance of MaximusRuboFormatter.
- #started(target_files) ⇒ Object
Constructor Details
#initialize(output) ⇒ MaximusRuboFormatter
Returns a new instance of MaximusRuboFormatter.
18 19 20 21 |
# File 'lib/maximus/reporter/rubocop.rb', line 18 def initialize(output) super @output_hash = {} end |
Instance Attribute Details
#output_hash ⇒ Object (readonly)
Returns the value of attribute output_hash.
16 17 18 |
# File 'lib/maximus/reporter/rubocop.rb', line 16 def output_hash @output_hash end |
Instance Method Details
#file_finished(file, offenses) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/maximus/reporter/rubocop.rb', line 26 def file_finished(file, offenses) unless offenses.empty? @output_hash[relative_path(file).to_sym] = {} @output_hash[relative_path(file).to_sym] = offenses.map { |o| hash_for_offense(o) } end end |
#finished(inspected_files) ⇒ Object
33 34 35 |
# File 'lib/maximus/reporter/rubocop.rb', line 33 def finished(inspected_files) output.write @output_hash.to_json end |
#hash_for_offense(offense) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/maximus/reporter/rubocop.rb', line 37 def hash_for_offense(offense) { severity: offense.severity.name, reason: offense., linter: offense.cop_name, line: offense.line, column: offense.real_column } end |
#started(target_files) ⇒ Object
23 24 |
# File 'lib/maximus/reporter/rubocop.rb', line 23 def started(target_files) end |