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) ⇒ Lint

Creates a new lint.

Parameters:

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


31
32
33
34
35
36
37
38
# File 'lib/haml_lint/lint.rb', line 31

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

Instance Attribute Details

#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



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

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



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

def line
  @line
end

#linterSlimLint::Linter (readonly)

Returns linter that reported the lint.

Returns:

  • (SlimLint::Linter)

    linter that reported the lint



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

def linter
  @linter
end

#messageString (readonly)

Returns error/warning message to display to user.

Returns:

  • (String)

    error/warning message to display to user



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

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



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

def severity
  @severity
end

Instance Method Details

#error?Boolean

Return whether this lint has a severity of error.

Returns:

  • (Boolean)


43
44
45
# File 'lib/haml_lint/lint.rb', line 43

def error?
  @severity.error?
end

#inspectObject



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

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