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(message, filename, line_number, info) ⇒ Warning
constructor
:nodoc:.
Constructor Details
#initialize(message, filename, line_number, info) ⇒ Warning
:nodoc:
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/simplabs/excellent/warning.rb', line 33 def initialize(, filename, line_number, info) #:nodoc: @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
16 17 18 |
# File 'lib/simplabs/excellent/warning.rb', line 16 def check @check end |
#filename ⇒ Object (readonly)
The name of the file the check found the problematic code in
19 20 21 |
# File 'lib/simplabs/excellent/warning.rb', line 19 def filename @filename end |
#info ⇒ Object (readonly)
Additional info for the warning (see above)
28 29 30 |
# File 'lib/simplabs/excellent/warning.rb', line 28 def info @info end |
#line_number ⇒ Object (readonly)
The file number where the check found the problematic code
22 23 24 |
# File 'lib/simplabs/excellent/warning.rb', line 22 def line_number @line_number end |
#message ⇒ Object (readonly)
The warning message
25 26 27 |
# File 'lib/simplabs/excellent/warning.rb', line 25 def @message end |
#message_template ⇒ Object (readonly)
The template used to produce the warning (see above)
31 32 33 |
# File 'lib/simplabs/excellent/warning.rb', line 31 def @message_template end |