Class: Rubydex::LinterConfig
- Inherits:
-
Object
- Object
- Rubydex::LinterConfig
- Defined in:
- lib/rubydex/config.rb,
ext/rubydex/config.c
Overview
The linter's settings, read from the [linter] section of the configuration file.
Instance Attribute Summary collapse
-
#rules ⇒ Object
readonly
The configured rules, keyed by rule name.
Instance Method Summary collapse
-
#excludes_for(rule_class) ⇒ Object
: (singleton(Rule) rule_class) -> Array.
-
#initialize(rules) ⇒ LinterConfig
constructor
: (Hash[String, RuleConfig]) -> void.
-
#rule_enabled?(rule_class) ⇒ Boolean
: (singleton(Rule) rule_class) -> bool.
-
#severity_for(rule_class) ⇒ Object
: (singleton(Rule) rule_class) -> singleton(Severity::Base)?.
Constructor Details
#initialize(rules) ⇒ LinterConfig
: (Hash[String, RuleConfig]) -> void
13 14 15 16 |
# File 'lib/rubydex/config.rb', line 13 def initialize(rules) @rules = rules.freeze freeze end |
Instance Attribute Details
#rules ⇒ Object (readonly)
The configured rules, keyed by rule name. Only rules the configuration file mentions appear here, so a rule that was never configured is absent rather than present with its defaults.
: Hash[String, RuleConfig]
10 11 12 |
# File 'lib/rubydex/config.rb', line 10 def rules @rules end |
Instance Method Details
#excludes_for(rule_class) ⇒ Object
: (singleton(Rule) rule_class) -> Array
25 26 27 |
# File 'lib/rubydex/config.rb', line 25 def excludes_for(rule_class) @rules[rule_class.rule_name]&.exclude_patterns || [] end |
#rule_enabled?(rule_class) ⇒ Boolean
: (singleton(Rule) rule_class) -> bool
19 20 21 22 |
# File 'lib/rubydex/config.rb', line 19 def rule_enabled?(rule_class) rule = @rules[rule_class.rule_name] !rule || rule.enabled? end |
#severity_for(rule_class) ⇒ Object
: (singleton(Rule) rule_class) -> singleton(Severity::Base)?
30 31 32 |
# File 'lib/rubydex/config.rb', line 30 def severity_for(rule_class) @rules[rule_class.rule_name]&.severity end |