Module: Shirobai::Cop::RSpec::SendCandidateSupport

Includes:
BundleEligible
Included in:
Focus, PendingWithoutReason
Defined in:
lib/shirobai/cop/rspec/send_candidate_support.rb

Overview

Shared harness for the send-based metadata-family cops (Focus, PendingWithoutReason).

Rust identifies candidate SEND ranges once on the shared walk; this module relocates each parser send node and hands it to the cop's investigate_send, which is stock's on_send copied verbatim (renamed so the Commissioner never dispatches a per-node on_send). Every guard, matcher, and parent-relationship check runs on the real parser AST.

Instance Method Summary collapse

Instance Method Details

#on_new_investigationObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/shirobai/cop/rspec/send_candidate_support.rb', line 17

def on_new_investigation
  RuboCop::RSpec::Language.config = config["RSpec"]["Language"]
  ranges = resolved_candidates
  return if ranges.nil? || ranges.empty?

  source = bundle_eligible? ? processed_source.raw_source : processed_source.buffer.source
  off = SourceOffsets.for(source)
  keys = ranges.map { |(start, fin)| [off[start], off[fin]] }
  located = Shirobai::RSpec::NodeLocator.locate(processed_source, keys)

  keys.each do |key|
    node = located[key]
    investigate_send(node) if node&.send_type?
  end
end