Class: SpecGuard::RSpec::Finding
- Inherits:
-
Object
- Object
- SpecGuard::RSpec::Finding
- Defined in:
- lib/specguard/rspec/finding.rb
Overview
One @intent: annotation, located and (where possible) parsed.
Exactly one of intent and problem is non-nil:
* `intent` — the parsed annotation as a Hash with String keys. Says
nothing about whether it is *valid*; schema validation is a later
stage, so a Finding with an `intent` may still be rejected then.
* `problem` — why this annotation could not be turned into a Hash at
all, as a human-readable sentence.
kind names how it failed and is nil when it did not. It is carried
here rather than reconstructed by the caller because a failed extraction
and an unparseable payload both land in problem, which makes the two
indistinguishable downstream once flattened to prose.
line is the 1-based line the annotation sits on — except under
KIND_READ, where nothing in the file was ever seen and
Scanner.scan_file / Scanner.scan_text construct the Finding with a
line of 0. That 0 is a sentinel standing in for "no line", not a
position anything can be pointed at.
NOTE: this is a subclass of an anonymous Data.define rather than a
Data.define do ... end block, because a constant assigned inside that
block binds to the lexically enclosing module (SpecGuard::RSpec) rather
than to the value class — so KIND_EXTRACTION below would silently not be
Finding::KIND_EXTRACTION.
Constant Summary collapse
- KIND_EXTRACTION =
The annotation's payload could not be captured off the line at all (unterminated literal, or no
{...}after the token). :extraction- KIND_PARSE =
The payload was captured but is not JSON even after normalization.
:parse- KIND_READ =
The file itself could not be read (missing, unopenable, or not valid UTF-8), so no annotation in it was ever seen. Distinct from KIND_EXTRACTION — nothing here is a claim about an annotation — and named after the
readkind the validator's--jsonreport carries, so the two classifications line up. :read- KIND_SCHEMA =
The payload parsed but violates the OpenTestIntent schema. Not produced by discovery — Linter stamps it — but it lives here so the full set of ways an annotation can fail is written down in one place.
:schema
Instance Method Summary collapse
-
#extracted? ⇒ Boolean
True when the annotation yielded a Hash.
-
#initialize(file:, line:, intent: nil, problem: nil, kind: nil) ⇒ Finding
constructor
A new instance of Finding.
- #problem? ⇒ Boolean
Constructor Details
#initialize(file:, line:, intent: nil, problem: nil, kind: nil) ⇒ Finding
Returns a new instance of Finding.
51 52 53 |
# File 'lib/specguard/rspec/finding.rb', line 51 def initialize(file:, line:, intent: nil, problem: nil, kind: nil) super end |
Instance Method Details
#extracted? ⇒ Boolean
True when the annotation yielded a Hash. Not a claim that it is valid.
56 57 58 |
# File 'lib/specguard/rspec/finding.rb', line 56 def extracted? problem.nil? end |
#problem? ⇒ Boolean
60 61 62 |
# File 'lib/specguard/rspec/finding.rb', line 60 def problem? !problem.nil? end |