Class: Rigor::Analysis::Diagnostic
- Inherits:
-
Object
- Object
- Rigor::Analysis::Diagnostic
- Defined in:
- lib/rigor/analysis/diagnostic.rb
Constant Summary collapse
- DEFAULT_SOURCE_FAMILY =
The default source family. Matches the existing analyzer- internal rule families; serialised as ‘“builtin”` and is the baseline against which non-default families are recognised.
:builtin
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#rule ⇒ Object
readonly
Returns the value of attribute rule.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
-
#source_family ⇒ Object
readonly
Returns the value of attribute source_family.
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(path:, line:, column:, message:, severity: :error, rule: nil, source_family: DEFAULT_SOURCE_FAMILY) ⇒ Diagnostic
constructor
‘rule:` is the stable identifier (a kebab-case string) of the diagnostic’s source rule.
-
#qualified_rule ⇒ Object
The fully-qualified rule identifier — ‘<source_family>.<rule>` when the source is non-default, or just `<rule>` for the `:builtin` family.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(path:, line:, column:, message:, severity: :error, rule: nil, source_family: DEFAULT_SOURCE_FAMILY) ⇒ 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.
‘source_family:` names the producer of the rule. The default `:builtin` covers analyzer-internal rules; future families like `:rbs_extended`, `:generated`, or `“plugin.<id>”` (per ADR-2 § “Plugin Diagnostic Provenance”) let consumers distinguish where a diagnostic originated without committing to the plugin API itself. rubocop:disable Metrics/ParameterLists
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rigor/analysis/diagnostic.rb', line 28 def initialize(path:, line:, column:, message:, severity: :error, rule: nil, source_family: DEFAULT_SOURCE_FAMILY) # rubocop:enable Metrics/ParameterLists @path = path @line = line @column = column @message = @severity = severity @rule = rule @source_family = source_family end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
11 12 13 |
# File 'lib/rigor/analysis/diagnostic.rb', line 11 def column @column end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
11 12 13 |
# File 'lib/rigor/analysis/diagnostic.rb', line 11 def line @line end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
11 12 13 |
# File 'lib/rigor/analysis/diagnostic.rb', line 11 def @message end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/rigor/analysis/diagnostic.rb', line 11 def path @path end |
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
11 12 13 |
# File 'lib/rigor/analysis/diagnostic.rb', line 11 def rule @rule end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
11 12 13 |
# File 'lib/rigor/analysis/diagnostic.rb', line 11 def severity @severity end |
#source_family ⇒ Object (readonly)
Returns the value of attribute source_family.
11 12 13 |
# File 'lib/rigor/analysis/diagnostic.rb', line 11 def source_family @source_family end |
Instance Method Details
#error? ⇒ Boolean
40 41 42 |
# File 'lib/rigor/analysis/diagnostic.rb', line 40 def error? severity == :error end |
#qualified_rule ⇒ Object
The fully-qualified rule identifier — ‘<source_family>.<rule>` when the source is non-default, or just `<rule>` for the `:builtin` family. Returns nil when `rule` itself is nil (e.g. parse errors and internal-analyzer errors).
48 49 50 51 52 53 |
# File 'lib/rigor/analysis/diagnostic.rb', line 48 def qualified_rule return nil if rule.nil? return rule if source_family == DEFAULT_SOURCE_FAMILY "#{source_family}.#{rule}" end |
#to_h ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rigor/analysis/diagnostic.rb', line 55 def to_h { "path" => path, "line" => line, "column" => column, "severity" => severity.to_s, "rule" => rule, "source_family" => source_family.to_s, "message" => } end |
#to_s ⇒ Object
67 68 69 |
# File 'lib/rigor/analysis/diagnostic.rb', line 67 def to_s "#{path}:#{line}:#{column}: #{severity}: #{}" end |