Class: Mdlint::Linter::Violation
- Inherits:
-
Object
- Object
- Mdlint::Linter::Violation
- Defined in:
- lib/mdlint/linter/violation.rb,
sig/mdlint.rbs,
sig/internal.rbs
Instance Attribute Summary collapse
-
#column ⇒ Integer?
readonly
Returns the value of attribute column.
-
#fixable ⇒ Boolean
readonly
Returns the value of attribute fixable.
-
#line ⇒ Integer
readonly
Returns the value of attribute line.
-
#message ⇒ String
readonly
Returns the value of attribute message.
-
#rule_id ⇒ String
readonly
Returns the value of attribute rule_id.
-
#severity ⇒ Symbol
readonly
Returns the value of attribute severity.
Instance Method Summary collapse
- #error? ⇒ Boolean
- #fixable? ⇒ Boolean
- #info? ⇒ Boolean
-
#initialize(rule_id:, message:, line:, column: nil, severity: :warning, fixable: false) ⇒ Violation
constructor
A new instance of Violation.
- #to_h ⇒ Hash[Symbol, untyped]
- #to_s ⇒ String
- #warning? ⇒ Boolean
Constructor Details
#initialize(rule_id:, message:, line:, column: nil, severity: :warning, fixable: false) ⇒ Violation
Returns a new instance of Violation.
8 9 10 11 12 13 14 15 |
# File 'lib/mdlint/linter/violation.rb', line 8 def initialize(rule_id:, message:, line:, column: nil, severity: :warning, fixable: false) @rule_id = rule_id @message = @line = line @column = column @severity = severity.to_sym @fixable = fixable end |
Instance Attribute Details
#column ⇒ Integer? (readonly)
Returns the value of attribute column.
6 7 8 |
# File 'lib/mdlint/linter/violation.rb', line 6 def column @column end |
#fixable ⇒ Boolean (readonly)
Returns the value of attribute fixable.
6 7 8 |
# File 'lib/mdlint/linter/violation.rb', line 6 def fixable @fixable end |
#line ⇒ Integer (readonly)
Returns the value of attribute line.
6 7 8 |
# File 'lib/mdlint/linter/violation.rb', line 6 def line @line end |
#message ⇒ String (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'lib/mdlint/linter/violation.rb', line 6 def @message end |
#rule_id ⇒ String (readonly)
Returns the value of attribute rule_id.
6 7 8 |
# File 'lib/mdlint/linter/violation.rb', line 6 def rule_id @rule_id end |
#severity ⇒ Symbol (readonly)
Returns the value of attribute severity.
6 7 8 |
# File 'lib/mdlint/linter/violation.rb', line 6 def severity @severity end |
Instance Method Details
#error? ⇒ Boolean
26 27 28 |
# File 'lib/mdlint/linter/violation.rb', line 26 def error? @severity == :error end |
#fixable? ⇒ Boolean
22 23 24 |
# File 'lib/mdlint/linter/violation.rb', line 22 def fixable? @fixable end |
#info? ⇒ Boolean
34 35 36 |
# File 'lib/mdlint/linter/violation.rb', line 34 def info? @severity == :info end |
#to_h ⇒ Hash[Symbol, untyped]
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mdlint/linter/violation.rb', line 38 def to_h { rule_id: @rule_id, message: @message, line: @line, column: @column, severity: @severity, fixable: @fixable } end |
#to_s ⇒ String
17 18 19 20 |
# File 'lib/mdlint/linter/violation.rb', line 17 def to_s location = column ? "#{line}:#{column}" : line.to_s "[#{rule_id}] #{location}: #{}" end |
#warning? ⇒ Boolean
30 31 32 |
# File 'lib/mdlint/linter/violation.rb', line 30 def warning? @severity == :warning end |