Class: Rubocop::Cop::Offence
- Inherits:
-
Object
- Object
- Rubocop::Cop::Offence
- Defined in:
- lib/rubocop/cop/offence.rb
Constant Summary collapse
- SEVERITIES =
[:refactor, :convention, :warning, :error, :fatal]
Instance Attribute Summary collapse
-
#line_number ⇒ Object
Returns the value of attribute line_number.
-
#message ⇒ Object
Returns the value of attribute message.
-
#severity ⇒ Object
Returns the value of attribute severity.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #encode_severity ⇒ Object
- #explode ⇒ Object
-
#initialize(severity, line_number, message) ⇒ Offence
constructor
A new instance of Offence.
- #to_s ⇒ Object
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, ) @severity = severity @line_number = line_number @message = end |
Instance Attribute Details
#line_number ⇒ Object
Returns the value of attribute line_number.
6 7 8 |
# File 'lib/rubocop/cop/offence.rb', line 6 def line_number @line_number end |
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/rubocop/cop/offence.rb', line 6 def @message end |
#severity ⇒ Object
Returns the value of attribute severity.
6 7 8 |
# File 'lib/rubocop/cop/offence.rb', line 6 def severity @severity end |
Instance Method Details
#==(other) ⇒ Object
26 27 28 29 |
# File 'lib/rubocop/cop/offence.rb', line 26 def ==(other) severity == other.severity && line_number == other.line_number && == other. end |
#encode_severity ⇒ Object
22 23 24 |
# File 'lib/rubocop/cop/offence.rb', line 22 def encode_severity @severity.to_s[0].upcase end |
#explode ⇒ Object
31 32 33 |
# File 'lib/rubocop/cop/offence.rb', line 31 def explode [severity, line_number, ] end |
#to_s ⇒ Object
16 17 18 19 20 |
# File 'lib/rubocop/cop/offence.rb', line 16 def to_s # we must be wary of messages containing % in them sprintf("#{encode_severity}:%3d: #{.gsub(/%/, '%%')}", line_number) end |