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 .rbs or through rbs-inline. One finding per (declaration, unrecognised token); a def self?.x member 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.yml label list: effects.tolerated:, effects.labels:, each envelopes[].effect and each attribution: 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

Class Method Details

.for_config(labels:, key_path:, consequence:, registry:) ⇒ Array<Finding>

Parameters:

  • labels (Array<String>)

    the list as written, in source order.

  • key_path (String)

    the .rigor.yml key, for the message (effects.tolerated).

  • consequence (String)

    what the degradation cost, for the message.

Returns:



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>

Parameters:

Returns:



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