Class: Rubocop::Cop::Offence

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

Constant Summary collapse

SEVERITIES =
[:refactor, :convention, :warning, :error, :fatal]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(severity, line_number, message) ⇒ Offence

Returns a new instance of Offence.



10
11
12
13
14
# File 'lib/rubocop/cop/offence.rb', line 10

def initialize(severity, line_number, message)
  @severity = severity
  @line_number = line_number
  @message = message
end

Instance Attribute Details

#line_numberObject

Returns the value of attribute line_number.



6
7
8
# File 'lib/rubocop/cop/offence.rb', line 6

def line_number
  @line_number
end

#messageObject

Returns the value of attribute message.



6
7
8
# File 'lib/rubocop/cop/offence.rb', line 6

def message
  @message
end

#severityObject

Returns the value of attribute severity.



6
7
8
# File 'lib/rubocop/cop/offence.rb', line 6

def severity
  @severity
end

Instance Method Details

#encode_severityObject



20
21
22
# File 'lib/rubocop/cop/offence.rb', line 20

def encode_severity
  @severity.to_s[0].upcase
end

#to_sObject



16
17
18
# File 'lib/rubocop/cop/offence.rb', line 16

def to_s
  "#{encode_severity}:%3d: #{message}" % [line_number]
end