Class: RuboCop::Formatter::MetzJsonFormatter
- Inherits:
-
JSONFormatter
- Object
- JSONFormatter
- RuboCop::Formatter::MetzJsonFormatter
- Defined in:
- lib/rubocop/formatter/metz_json_formatter.rb
Overview
Wraps RuboCop's standard JSON formatter and enriches every offense whose
cop_name starts with Metz/ with the metadata DSL fields published by
Metz::CopMetadata. Non-Metz offenses are passed through unchanged so the
top-level JSON shape and any consumer expecting standard RuboCop output
keeps working.
Constant Summary collapse
- METZ_PREFIX =
"Metz/"- EMPTY_METADATA =
{ why_it_matters: nil, fix_safety: nil, suggested_next_moves: [] }.freeze
Instance Method Summary collapse
Instance Method Details
#hash_for_offense(offense) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/rubocop/formatter/metz_json_formatter.rb', line 21 def hash_for_offense(offense) hash = super return hash unless offense.cop_name.to_s.start_with?(METZ_PREFIX) hash.merge!((offense.cop_name)) end |