Module: Shirobai::Cop::Rails::CandidateSupport

Includes:
BundleEligible
Included in:
DeprecatedActiveModelErrorsMethods, HttpPositionalArguments
Defined in:
lib/shirobai/cop/rails/candidate_support.rb

Overview

Shared harness for the Architecture-B Rails cops (HttpPositionalArguments, DeprecatedActiveModelErrorsMethods).

Rust identifies candidate SEND ranges once on the shared walk; this module relocates each parser send node (Shirobai::NodeLocator) 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, receiver walk and autocorrect runs on the real parser AST, so detection and -A bytes match stock exactly; the Rust prefilter only narrows which nodes are visited.

The candidate set is a superset — false positives (e.g. a routing-block get, a non-model bare errors) are dropped by the stock matchers the wrapper re-runs.

Instance Method Summary collapse

Instance Method Details

#on_new_investigationObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/shirobai/cop/rails/candidate_support.rb', line 24

def on_new_investigation
  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::NodeLocator.locate(processed_source, keys)

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