Class: Simplabs::Excellent::Warning
- Inherits:
-
Object
- Object
- Simplabs::Excellent::Warning
- Defined in:
- lib/simplabs/excellent/warning.rb
Overview
The warnings returned by Excellent provide information about the file the possibly problematic code was found in as well as the line of the occurence, a warning message and a Hash with specific information about the warning.
Warnings also provide the message template that was used to generate the message. The message template contains tokens like {{token}} that correspond to the valeus in the info hash, e.g.:
'{{method}} has abc score of {{score}}.'
{ :method => 'User#full_name', :score => 10 }
Instance Attribute Summary collapse
-
#check ⇒ Object
readonly
The check that produced the warning.
-
#filename ⇒ Object
readonly
The name of the file the check found the problematic code in.
-
#info ⇒ Object
readonly
Additional info for the warning (see above).
-
#line_number ⇒ Object
readonly
The file number where the check found the problematic code.
-
#message ⇒ Object
readonly
The warning message.
-
#message_template ⇒ Object
readonly
The template used to produce the warning (see above).
Instance Method Summary collapse
-
#initialize(check, message, filename, line_number, info) ⇒ Warning
constructor
:nodoc:.
Constructor Details
#initialize(check, message, filename, line_number, info) ⇒ Warning
:nodoc:
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/simplabs/excellent/warning.rb', line 35 def initialize(check, , filename, line_number, info) #:nodoc: @check = check.to_s.underscore.to_sym @info = info @filename = filename @line_number = line_number.to_i @message = '' if !.nil? @message_template = @info.each { |key, value| .gsub!(/\{\{#{key}\}\}/, value.to_s) } @message = end end |
Instance Attribute Details
#check ⇒ Object (readonly)
The check that produced the warning
18 19 20 |
# File 'lib/simplabs/excellent/warning.rb', line 18 def check @check end |
#filename ⇒ Object (readonly)
The name of the file the check found the problematic code in
21 22 23 |
# File 'lib/simplabs/excellent/warning.rb', line 21 def filename @filename end |
#info ⇒ Object (readonly)
Additional info for the warning (see above)
30 31 32 |
# File 'lib/simplabs/excellent/warning.rb', line 30 def info @info end |
#line_number ⇒ Object (readonly)
The file number where the check found the problematic code
24 25 26 |
# File 'lib/simplabs/excellent/warning.rb', line 24 def line_number @line_number end |
#message ⇒ Object (readonly)
The warning message
27 28 29 |
# File 'lib/simplabs/excellent/warning.rb', line 27 def @message end |
#message_template ⇒ Object (readonly)
The template used to produce the warning (see above)
33 34 35 |
# File 'lib/simplabs/excellent/warning.rb', line 33 def @message_template end |