Class: Rigor::Analysis::Diagnostic

Inherits:
Object
  • Object
show all
Defined in:
lib/rigor/analysis/diagnostic.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, line:, column:, message:, severity: :error, rule: nil) ⇒ Diagnostic

‘rule:` is the stable identifier (a kebab-case string) of the diagnostic’s source rule. It is used by the configuration and the in-source ‘# rigor:disable <rule>` suppression comment system to identify diagnostics by category. Diagnostics not produced by `CheckRules` (parse errors, path errors, internal analyzer errors) may leave `rule` as nil and stay unsuppressible. rubocop:disable Metrics/ParameterLists



16
17
18
19
20
21
22
23
24
# File 'lib/rigor/analysis/diagnostic.rb', line 16

def initialize(path:, line:, column:, message:, severity: :error, rule: nil)
  # rubocop:enable Metrics/ParameterLists
  @path = path
  @line = line
  @column = column
  @message = message
  @severity = severity
  @rule = rule
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



6
7
8
# File 'lib/rigor/analysis/diagnostic.rb', line 6

def column
  @column
end

#lineObject (readonly)

Returns the value of attribute line.



6
7
8
# File 'lib/rigor/analysis/diagnostic.rb', line 6

def line
  @line
end

#messageObject (readonly)

Returns the value of attribute message.



6
7
8
# File 'lib/rigor/analysis/diagnostic.rb', line 6

def message
  @message
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/rigor/analysis/diagnostic.rb', line 6

def path
  @path
end

#ruleObject (readonly)

Returns the value of attribute rule.



6
7
8
# File 'lib/rigor/analysis/diagnostic.rb', line 6

def rule
  @rule
end

#severityObject (readonly)

Returns the value of attribute severity.



6
7
8
# File 'lib/rigor/analysis/diagnostic.rb', line 6

def severity
  @severity
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/rigor/analysis/diagnostic.rb', line 26

def error?
  severity == :error
end

#to_hObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/rigor/analysis/diagnostic.rb', line 30

def to_h
  {
    "path" => path,
    "line" => line,
    "column" => column,
    "severity" => severity.to_s,
    "rule" => rule,
    "message" => message
  }
end

#to_sObject



41
42
43
# File 'lib/rigor/analysis/diagnostic.rb', line 41

def to_s
  "#{path}:#{line}:#{column}: #{severity}: #{message}"
end