Class: Rubocop::Cop::Cop

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/cop/cop.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCop

Returns a new instance of Cop.



49
50
51
# File 'lib/rubocop/cop/cop.rb', line 49

def initialize
  @offences = []
end

Class Attribute Details

.allObject

Returns the value of attribute all.



41
42
43
# File 'lib/rubocop/cop/cop.rb', line 41

def all
  @all
end

.configObject

Returns the value of attribute config.



42
43
44
# File 'lib/rubocop/cop/cop.rb', line 42

def config
  @config
end

Instance Attribute Details

#correlations=(value) ⇒ Object (writeonly)

Sets the attribute correlations

Parameters:

  • value

    the value to set the attribute correlations to.



35
36
37
# File 'lib/rubocop/cop/cop.rb', line 35

def correlations=(value)
  @correlations = value
end

#offencesObject

Returns the value of attribute offences.



34
35
36
# File 'lib/rubocop/cop/cop.rb', line 34

def offences
  @offences
end

Class Method Details

.inherited(subclass) ⇒ Object



45
46
47
# File 'lib/rubocop/cop/cop.rb', line 45

def self.inherited(subclass)
  all << subclass
end

Instance Method Details

#add_offence(severity, line_number, message) ⇒ Object



57
58
59
# File 'lib/rubocop/cop/cop.rb', line 57

def add_offence(severity, line_number, message)
  @offences << Offence.new(severity, line_number, message)
end

#has_report?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/rubocop/cop/cop.rb', line 53

def has_report?
  !@offences.empty?
end