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.
78 79 80 |
# File 'lib/specguard/rspec/linter.rb', line 78 def initialize(file:, line:, kind: nil, problem: nil, reasons: []) super end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file
77 78 79 |
# File 'lib/specguard/rspec/linter.rb', line 77 def file @file end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind
77 78 79 |
# File 'lib/specguard/rspec/linter.rb', line 77 def kind @kind end |
#line ⇒ Object (readonly)
Returns the value of attribute line
77 78 79 |
# File 'lib/specguard/rspec/linter.rb', line 77 def line @line end |
#problem ⇒ Object (readonly)
Returns the value of attribute problem
77 78 79 |
# File 'lib/specguard/rspec/linter.rb', line 77 def problem @problem end |
#reasons ⇒ Object (readonly)
Returns the value of attribute reasons
77 78 79 |
# File 'lib/specguard/rspec/linter.rb', line 77 def reasons @reasons end |
Instance Method Details
#failed? ⇒ Boolean
86 87 88 |
# File 'lib/specguard/rspec/linter.rb', line 86 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
binary drops the line for exactly these findings (JSONFinding in
open-test-intent's cmd/validate-intent/report.go — "line is null
where a finding is not line-scoped, kind is null on a passing
finding"), 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.
106 107 108 |
# File 'lib/specguard/rspec/linter.rb', line 106 def line_scoped? kind != Finding::KIND_READ end |
#location ⇒ Object
110 111 112 |
# File 'lib/specguard/rspec/linter.rb', line 110 def location line_scoped? ? "#{file}:#{line}" : file end |
#ok? ⇒ Boolean
82 83 84 |
# File 'lib/specguard/rspec/linter.rb', line 82 def ok? problem.nil? && reasons.empty? end |