Class: Collie::Linter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/collie/linter/base.rb

Overview

Base class for all lint rules

Constant Summary collapse

VALID_SEVERITIES =
%i[error warning convention info].freeze

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Base

Returns a new instance of Base.



37
38
39
40
# File 'lib/collie/linter/base.rb', line 37

def initialize(config = {})
  @config = config
  @offenses = []
end

Class Attribute Details

.autocorrectableObject

Returns the value of attribute autocorrectable.



34
35
36
# File 'lib/collie/linter/base.rb', line 34

def autocorrectable
  @autocorrectable
end

.descriptionObject

Returns the value of attribute description.



34
35
36
# File 'lib/collie/linter/base.rb', line 34

def description
  @description
end

.rule_nameObject

Returns the value of attribute rule_name.



34
35
36
# File 'lib/collie/linter/base.rb', line 34

def rule_name
  @rule_name
end

.severityObject

Returns the value of attribute severity.



34
35
36
# File 'lib/collie/linter/base.rb', line 34

def severity
  @severity
end

Instance Method Details

#autocorrectable?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/collie/linter/base.rb', line 46

def autocorrectable?
  self.class.autocorrectable
end

#check(_ast, _context = {}) ⇒ Object

Raises:

  • (NotImplementedError)


42
43
44
# File 'lib/collie/linter/base.rb', line 42

def check(_ast, _context = {})
  raise NotImplementedError, "#{self.class} must implement #check"
end