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
-
#filename ⇒ String
readonly
File path to which the lint applies.
-
#linter ⇒ SlimLint::Linter
readonly
Linter that reported the lint.
-
#location ⇒ SourceLocation
readonly
Location in the file the lint corresponds to.
-
#message ⇒ String
readonly
Error/warning message to display to user.
-
#severity ⇒ Symbol
readonly
Whether this lint is a warning or an error.
-
#sublinter ⇒ String
readonly
Sublinter that reported the lint.
Instance Method Summary collapse
- #column ⇒ Object
- #cop ⇒ Object
-
#error? ⇒ Boolean
Return whether this lint has a severity of error.
-
#initialize(linter, filename, location, message, severity = :warning) ⇒ Lint
constructor
Creates a new lint.
- #last_column ⇒ Object
- #last_line ⇒ Object
- #line ⇒ Object
- #name ⇒ Object
Constructor Details
#initialize(linter, filename, location, message, severity = :warning) ⇒ Lint
Creates a new lint.
31 32 33 34 35 36 37 |
# File 'lib/slim_lint/lint.rb', line 31 def initialize(linter, filename, location, , severity = :warning) @linter, @sublinter = Array(linter) @filename = filename @location = location @message = @severity = severity end |
Instance Attribute Details
#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 |
#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 |
#location ⇒ SourceLocation (readonly)
Returns location in the file the lint corresponds to.
10 11 12 |
# File 'lib/slim_lint/lint.rb', line 10 def location @location end |
#message ⇒ String (readonly)
Returns error/warning message to display to user.
19 20 21 |
# File 'lib/slim_lint/lint.rb', line 19 def @message end |
#severity ⇒ Symbol (readonly)
Returns whether this lint is a warning or an error.
22 23 24 |
# File 'lib/slim_lint/lint.rb', line 22 def severity @severity end |
#sublinter ⇒ String (readonly)
Returns sublinter that reported the lint.
16 17 18 |
# File 'lib/slim_lint/lint.rb', line 16 def sublinter @sublinter end |
Instance Method Details
#column ⇒ Object
43 44 45 |
# File 'lib/slim_lint/lint.rb', line 43 def column location.column end |
#cop ⇒ Object
55 56 57 |
# File 'lib/slim_lint/lint.rb', line 55 def cop @sublinter || @linter.name if @linter end |
#error? ⇒ Boolean
Return whether this lint has a severity of error.
66 67 68 |
# File 'lib/slim_lint/lint.rb', line 66 def error? @severity == :error end |
#last_column ⇒ Object
51 52 53 |
# File 'lib/slim_lint/lint.rb', line 51 def last_column location.last_column end |
#last_line ⇒ Object
47 48 49 |
# File 'lib/slim_lint/lint.rb', line 47 def last_line location.last_line end |
#line ⇒ Object
39 40 41 |
# File 'lib/slim_lint/lint.rb', line 39 def line location.line end |
#name ⇒ Object
59 60 61 |
# File 'lib/slim_lint/lint.rb', line 59 def name [@linter.name, @sublinter].compact.join("/") if @linter end |