Class: Rubydex::Rule Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/rubydex/rule.rb

Overview

This class is abstract.

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.

Class Method Summary collapse

Class Method Details

.default_severityObject

This method is abstract.

: () -> singleton(Severity::Base)

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/rubydex/rule.rb', line 21

def default_severity
  raise NotImplementedError, "Subclasses must implement the default_severity method"
end

.rule_nameObject

: () -> 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