Class: Rubydex::Rule Abstract
- Inherits:
-
Object
- Object
- Rubydex::Rule
- Defined in:
- lib/rubydex/rule.rb
Overview
The identity of a rule. We have different mechanisms for collecting diagnostics, but they all share the same fundamental identity: a unique name and a default severity that may be overridden by the user's configuration.
By keeping this identity concept unified, we are able to treat rules consistently regardless of whether they were collected by the graph during the analysis or by the linter afterwards.
Direct Known Subclasses
Linter::CustomRule, Rubydex::Rules::DynamicAncestor, Rubydex::Rules::DynamicConstantReference, Rubydex::Rules::DynamicSingletonDefinition, Rubydex::Rules::InvalidConstantVisibility, Rubydex::Rules::InvalidMethodVisibility, Rubydex::Rules::ParseError, Rubydex::Rules::ParseWarning, Rubydex::Rules::TopLevelMixinSelf, Rubydex::Rules::UndefinedConstantVisibilityTarget, Rubydex::Rules::UndefinedMethodVisibilityTarget
Class Method Summary collapse
-
.default_severity ⇒ Object
abstract
: () -> singleton(Severity::Base).
-
.rule_name ⇒ Object
: () -> String.
-
.severity(config) ⇒ Object
Returns the resolved severity of the rule based on the given configuration.
Class Method Details
.default_severity ⇒ Object
: () -> singleton(Severity::Base)
21 22 23 |
# File 'lib/rubydex/rule.rb', line 21 def default_severity raise NotImplementedError, "Subclasses must implement the default_severity method" end |
.rule_name ⇒ Object
: () -> String
14 15 16 17 |
# File 'lib/rubydex/rule.rb', line 14 def rule_name name #: as !nil .split("::").last #: as !nil end |
.severity(config) ⇒ Object
Returns the resolved severity of the rule based on the given configuration.
: (LinterConfig) -> singleton(Severity::Base)
28 29 30 |
# File 'lib/rubydex/rule.rb', line 28 def severity(config) config.severity_for(self) || default_severity end |