Class: SlimLint::Lint
- Inherits:
-
Object
- Object
- SlimLint::Lint
- Defined in:
- lib/slim_lint/lint.rb
Overview
Contains information about a problem or issue with a Slim document.
Instance Attribute Summary collapse
-
#corrected ⇒ Boolean
Whether this lint's correction has been applied.
-
#correction ⇒ Proc?
readonly
Maps a line of source to its corrected version (
nilto remove the line, or a string with embedded newlines to replace it with multiple lines), ornilif this lint has no known automatic correction. -
#filename ⇒ String
readonly
File path to which the lint applies.
-
#line ⇒ String
readonly
Line number of the file the lint corresponds to.
-
#linter ⇒ SlimLint::Linter
readonly
Linter that reported the lint.
-
#message ⇒ String
readonly
Error/warning message to display to user.
-
#severity ⇒ Symbol
readonly
Whether this lint is a warning or an error.
Instance Method Summary collapse
-
#correctable? ⇒ Boolean
Return whether this lint has a known automatic correction.
-
#corrected? ⇒ Boolean
Return whether this lint's correction has been applied.
-
#error? ⇒ Boolean
Return whether this lint has a severity of error.
-
#initialize(linter, filename, line, message, severity = :warning, correction: nil) ⇒ Lint
constructor
Creates a new lint.
Constructor Details
#initialize(linter, filename, line, message, severity = :warning, correction: nil) ⇒ Lint
Creates a new lint.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/slim_lint/lint.rb', line 38 def initialize(linter, filename, line, , severity = :warning, # rubocop:disable Metrics/ParameterLists correction: nil) @linter = linter @filename = filename @line = line || 0 @message = @severity = severity @correction = correction @corrected = false end |
Instance Attribute Details
#corrected ⇒ Boolean
Returns whether this lint's correction has been applied.
28 29 30 |
# File 'lib/slim_lint/lint.rb', line 28 def corrected @corrected end |
#correction ⇒ Proc? (readonly)
Returns maps a line of source to its corrected version
(nil to remove the line, or a string with embedded newlines to
replace it with multiple lines), or nil if this lint has no known
automatic correction.
25 26 27 |
# File 'lib/slim_lint/lint.rb', line 25 def correction @correction end |
#filename ⇒ String (readonly)
Returns file path to which the lint applies.
7 8 9 |
# File 'lib/slim_lint/lint.rb', line 7 def filename @filename end |
#line ⇒ String (readonly)
Returns line number of the file the lint corresponds to.
10 11 12 |
# File 'lib/slim_lint/lint.rb', line 10 def line @line end |
#linter ⇒ SlimLint::Linter (readonly)
Returns linter that reported the lint.
13 14 15 |
# File 'lib/slim_lint/lint.rb', line 13 def linter @linter end |
#message ⇒ String (readonly)
Returns error/warning message to display to user.
16 17 18 |
# File 'lib/slim_lint/lint.rb', line 16 def @message end |
#severity ⇒ Symbol (readonly)
Returns whether this lint is a warning or an error.
19 20 21 |
# File 'lib/slim_lint/lint.rb', line 19 def severity @severity end |
Instance Method Details
#correctable? ⇒ Boolean
Return whether this lint has a known automatic correction.
59 60 61 |
# File 'lib/slim_lint/lint.rb', line 59 def correctable? !@correction.nil? end |
#corrected? ⇒ Boolean
Return whether this lint's correction has been applied.
66 67 68 |
# File 'lib/slim_lint/lint.rb', line 66 def corrected? @corrected end |
#error? ⇒ Boolean
Return whether this lint has a severity of error.
52 53 54 |
# File 'lib/slim_lint/lint.rb', line 52 def error? @severity == :error end |