Class: SpecGuard::RSpec::Linter::Result
- Inherits:
-
Data
- Object
- Data
- SpecGuard::RSpec::Linter::Result
- Defined in:
- lib/specguard/rspec/linter.rb
Overview
One annotation's verdict. problem is set when discovery could not
produce an intent at all; reasons when the schema rejected one.
They are mutually exclusive by construction.
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#problem ⇒ Object
readonly
Returns the value of attribute problem.
-
#reasons ⇒ Object
readonly
Returns the value of attribute reasons.
Instance Method Summary collapse
- #failed? ⇒ Boolean
-
#initialize(file:, line:, kind: nil, problem: nil, reasons: []) ⇒ Result
constructor
A new instance of Result.
-
#line_scoped? ⇒ Boolean
A read failure is not line-scoped: nothing in the file was ever seen, and slice 1's
lineis a 0 sentinel rather than a location. - #location ⇒ Object
- #ok? ⇒ Boolean
Constructor Details
#initialize(file:, line:, kind: nil, problem: nil, reasons: []) ⇒ Result
Returns a new instance of Result.
74 75 76 |
# File 'lib/specguard/rspec/linter.rb', line 74 def initialize(file:, line:, kind: nil, problem: nil, reasons: []) super end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file
73 74 75 |
# File 'lib/specguard/rspec/linter.rb', line 73 def file @file end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind
73 74 75 |
# File 'lib/specguard/rspec/linter.rb', line 73 def kind @kind end |
#line ⇒ Object (readonly)
Returns the value of attribute line
73 74 75 |
# File 'lib/specguard/rspec/linter.rb', line 73 def line @line end |
#problem ⇒ Object (readonly)
Returns the value of attribute problem
73 74 75 |
# File 'lib/specguard/rspec/linter.rb', line 73 def problem @problem end |
#reasons ⇒ Object (readonly)
Returns the value of attribute reasons
73 74 75 |
# File 'lib/specguard/rspec/linter.rb', line 73 def reasons @reasons end |
Instance Method Details
#failed? ⇒ Boolean
82 83 84 |
# File 'lib/specguard/rspec/linter.rb', line 82 def failed? !ok? end |
#line_scoped? ⇒ Boolean
A read failure is not line-scoped: nothing in the file was ever seen,
and slice 1's line is a 0 sentinel rather than a location. The
reference drops the line for exactly these findings
(bin/validate-intent:521 — "when a finding is not line-scoped ...
kind is null"), and :0 is not somewhere a reader can go: anything
parsing file:line — CI annotations, editor quickfix, review
comments — would point at a line that does not exist.
This is what makes kind load-bearing rather than decorative.
The rule is a predicate rather than an inline comparison because it
now has two renderers: CLI#report_failure prints file instead of
file:0, and JSONReporter emits "line": null for the same
findings. Spelling kind == Finding::KIND_READ in both would let one
of them keep emitting the sentinel after the rule changed here.
101 102 103 |
# File 'lib/specguard/rspec/linter.rb', line 101 def line_scoped? kind != Finding::KIND_READ end |
#location ⇒ Object
105 106 107 |
# File 'lib/specguard/rspec/linter.rb', line 105 def location line_scoped? ? "#{file}:#{line}" : file end |
#ok? ⇒ Boolean
78 79 80 |
# File 'lib/specguard/rspec/linter.rb', line 78 def ok? problem.nil? && reasons.empty? end |