Class: Rubydex::LinterConfig

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#rulesObject (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

Returns:

  • (Boolean)


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