Module: RuboCop::ExcludeLimit
- Defined in:
- lib/rubocop/cop/exclude_limit.rb
Overview
Allows specified configuration options to have an exclude limit
ie. a maximum value tracked that it can be used by --auto-gen-config
.
Instance Method Summary collapse
-
#exclude_limit(parameter_name, method_name: transform(parameter_name)) ⇒ Object
Sets up a configuration option to have an exclude limit tracked.
Instance Method Details
#exclude_limit(parameter_name, method_name: transform(parameter_name)) ⇒ Object
Sets up a configuration option to have an exclude limit tracked.
The parameter name given is transformed into a method name (eg. Max
becomes self.max=
and MinDigits
becomes self.min_digits=
).
10 11 12 13 14 15 16 17 18 |
# File 'lib/rubocop/cop/exclude_limit.rb', line 10 def exclude_limit(parameter_name, method_name: transform(parameter_name)) define_method("#{method_name}=") do |value| cfg = config_to_allow_offenses cfg[:exclude_limit] ||= {} current_max = cfg[:exclude_limit][parameter_name] value = [current_max, value].max if current_max cfg[:exclude_limit][parameter_name] = value end end |