Module: Rigor::Effects::UnknownLabelCheck
- Defined in:
- lib/rigor/effects/unknown_label_check.rb
Overview
Turns the declarations a run carries into effect.unknown-label findings (ADR-103 WD1 / WD14;
#384). Pure: it reads envelopes and config values and answers value objects, never diagnostics
and never the filesystem — positioning the finding is the caller's job, because only the caller
knows whether a virtual: buffer has to be mapped back to the .rb the author wrote in.
Two producers today, one shape:
- UnknownLabelCheck.for_envelopes — every
%a{pure}/%a{rigor:v1:effect …}the envelope scanner read, in.rbsor through rbs-inline. One finding per (declaration, unrecognised token); adef self?.xmember declares two keys off ONE annotation, so findings are deduplicated by where they were written rather than by which method they bind. - UnknownLabelCheck.for_config — a
.rigor.ymllabel list:effects.tolerated:,effects.labels:, eachenvelopes[].effectand eachattribution:value. The key path is a parameter rather than a literal precisely because there are four of them and each names a different place to edit.
Defined Under Namespace
Classes: Finding
Constant Summary collapse
- ENVELOPE_CONSEQUENCE =
"the annotation now bounds nothing"
Class Method Summary collapse
- .for_config(labels:, key_path:, consequence:, registry:) ⇒ Array<Finding>
- .for_envelopes(method_envelopes:, class_envelopes:, registry:) ⇒ Array<Finding>
Class Method Details
.for_config(labels:, key_path:, consequence:, registry:) ⇒ Array<Finding>
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rigor/effects/unknown_label_check.rb', line 56 def for_config(labels:, key_path:, consequence:, registry:) tokens = Array(labels).map(&:to_s) tokens.filter_map do |token| report = UnknownLabelReport.for(token: token, registry: registry, siblings: tokens) next if report.nil? Finding.new( token: token, subject: "`#{key_path}:` in .rigor.yml", consequence: consequence, location: nil, spelling: nil, report: report ) end end |
.for_envelopes(method_envelopes:, class_envelopes:, registry:) ⇒ Array<Finding>
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rigor/effects/unknown_label_check.rb', line 37 def for_envelopes(method_envelopes:, class_envelopes:, registry:) seen = {} declarations(method_envelopes, class_envelopes).each do |envelope| envelope.unknown_labels.each do |token| report = UnknownLabelReport.for( token: token, registry: registry, siblings: envelope.declared_labels ) next if report.nil? seen[[envelope.location, envelope.spelling, token]] ||= envelope_finding(envelope, token, report) end end seen.values end |