Class: RuboCop::OffenseLimit Private
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | lib/rubocop/offense_limit.rb |
Overview
Caps how many offenses each cop gets to report.
Counted across a whole run rather than per file, since a cop that fires a handful of times in every file is exactly the one worth capping. Offenses have to be offered in a stable order (files in the order they are reported) for the same ones to survive every time.
Class Method Summary
- .new(max) ⇒ OffenseLimit constructor Internal use only
Instance Attribute Summary
- #max readonly Internal use only
Instance Method Summary
- #elided_per_cop ⇒ Hash{String => Integer} Internal use only
- #filter(offenses) ⇒ Array<Cop::Offense> Internal use only
Constructor Details
.new(max) ⇒ OffenseLimit
Instance Attribute Details
#max (readonly)
[ GitHub ]# File 'lib/rubocop/offense_limit.rb', line 12
attr_reader :max
Instance Method Details
#elided_per_cop ⇒ Hash{String => Integer}
# File 'lib/rubocop/offense_limit.rb', line 26
def elided_per_cop @offered.filter_map { |cop, count| [cop, count - @max] if count > @max }.sort.to_h end
#filter(offenses) ⇒ Array<Cop::Offense>
# File 'lib/rubocop/offense_limit.rb', line 20
def filter(offenses) offenses.select { |offense| (@offered[offense.cop_name] += 1) <= @max } end