Class: SlimLint::Lint

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

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(linter, filename, location, message, severity = :warning) ⇒ Lint

Creates a new lint.

Parameters:



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

def initialize(linter, filename, location, message, severity = :warning)
  @linter, @sublinter = Array(linter)
  @filename = filename
  @location = location
  @message = message
  @severity = severity
end

Instance Attribute Details

#filenameString (readonly)

Returns file path to which the lint applies.

Returns:

  • (String)

    file path to which the lint applies



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

def filename
  @filename
end

#linterSlimLint::Linter (readonly)

Returns linter that reported the lint.

Returns:



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

def linter
  @linter
end

#locationSourceLocation (readonly)

Returns location in the file the lint corresponds to.

Returns:



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

def location
  @location
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/slim_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/slim_lint/lint.rb', line 22

def severity
  @severity
end

#sublinterString (readonly)

Returns sublinter that reported the lint.

Returns:

  • (String)

    sublinter that reported the lint



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

def sublinter
  @sublinter
end

Instance Method Details

#columnObject



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

def column
  location.column
end

#copObject



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.

Returns:

  • (Boolean)


66
67
68
# File 'lib/slim_lint/lint.rb', line 66

def error?
  @severity == :error
end

#last_columnObject



51
52
53
# File 'lib/slim_lint/lint.rb', line 51

def last_column
  location.last_column
end

#last_lineObject



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

def last_line
  location.last_line
end

#lineObject



39
40
41
# File 'lib/slim_lint/lint.rb', line 39

def line
  location.line
end

#nameObject



59
60
61
# File 'lib/slim_lint/lint.rb', line 59

def name
  [@linter.name, @sublinter].compact.join("/") if @linter
end