Class: HamlLint::Lint

Inherits:
Object
  • Object
show all
Defined in:
lib/haml_lint/lint.rb

Overview

Contains information about a problem or issue with a Haml document.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(linter, filename, line, message, severity = :warning, corrected: false, correctable: false) ⇒ Lint

Creates a new lint.

Parameters:

  • linter (HamlLint::Linter)
  • filename (String)
  • line (Fixnum)
  • message (String)
  • severity (Symbol) (defaults to: :warning)


34
35
36
37
38
39
40
41
42
# File 'lib/haml_lint/lint.rb', line 34

def initialize(linter, filename, line, message, severity = :warning, corrected: false, correctable: false) # rubocop:disable Metrics/ParameterLists
  @linter   = linter
  @filename = filename
  @line     = line || 0
  @message  = message
  @severity = Severity.new(severity)
  @corrected = corrected
  @correctable = correctable
end

Instance Attribute Details

#correctableBoolean (readonly)

Returns If the error could be corrected by auto-correct.

Returns:

  • (Boolean)

    If the error could be corrected by auto-correct



10
11
12
# File 'lib/haml_lint/lint.rb', line 10

def correctable
  @correctable
end

#correctedBoolean (readonly)

Returns If the error was corrected by auto-correct.

Returns:

  • (Boolean)

    If the error was corrected by auto-correct



7
8
9
# File 'lib/haml_lint/lint.rb', line 7

def corrected
  @corrected
end

#filenameString (readonly)

Returns file path to which the lint applies.

Returns:

  • (String)

    file path to which the lint applies



13
14
15
# File 'lib/haml_lint/lint.rb', line 13

def filename
  @filename
end

#lineString (readonly)

Returns line number of the file the lint corresponds to.

Returns:

  • (String)

    line number of the file the lint corresponds to



16
17
18
# File 'lib/haml_lint/lint.rb', line 16

def line
  @line
end

#linterSlimLint::Linter (readonly)

Returns linter that reported the lint.

Returns:

  • (SlimLint::Linter)

    linter that reported the lint



19
20
21
# File 'lib/haml_lint/lint.rb', line 19

def linter
  @linter
end

#messageString (readonly)

Returns error/warning message to display to user.

Returns:

  • (String)

    error/warning message to display to user



22
23
24
# File 'lib/haml_lint/lint.rb', line 22

def message
  @message
end

#severitySymbol (readonly)

Returns whether this lint is a warning or an error.

Returns:

  • (Symbol)

    whether this lint is a warning or an error



25
26
27
# File 'lib/haml_lint/lint.rb', line 25

def severity
  @severity
end

Instance Method Details

#error?Boolean

Return whether this lint has a severity of error.

Returns:

  • (Boolean)


47
48
49
# File 'lib/haml_lint/lint.rb', line 47

def error?
  @severity.error?
end

#inspectObject



51
52
53
54
55
# File 'lib/haml_lint/lint.rb', line 51

def inspect
  "#{self.class.name}(corrected=#{corrected}, correctable=#{correctable}, " \
    "filename=#{filename}, line=#{line}, " \
    "linter=#{linter.class.name}, message=#{message}, severity=#{severity})"
end