Module: Shirobai::Cop::BundleEligible
- Included in:
- Layout::EmptyComment, Layout::EmptyLineAfterMagicComment, Layout::EmptyLines, Layout::LeadingEmptyLines, Layout::SpaceAfterColon, Layout::SpaceAfterComma, Layout::SpaceAfterSemicolon, Layout::SpaceBeforeComma, Layout::SpaceBeforeComment, Layout::SpaceBeforeFirstArg, Layout::SpaceBeforeSemicolon, Layout::SpaceInsideParens, Layout::SpaceInsideReferenceBrackets, Layout::TrailingEmptyLines, Lint::DuplicateMagicComment, Lint::DuplicateMethods, Style::ArgumentsForwarding, Style::FileNull, Style::FrozenStringLiteralComment, Style::IfUnlessModifier, Style::Semicolon
- Defined in:
- lib/shirobai/cop/base.rb
Overview
Shared bundle_eligible? for wrapper cops.
The bundled (shared-walk) path scans raw_source; the standalone path
scans the parser-normalized buffer.source. The two agree only when they
are byte-identical (CRLF / BOM / __END__ truncation break that), so a cop
may take the bundle path exactly then; otherwise it falls back so every
offset lines up with parser-gem's index.
The verdict is memoized, but the memo is guarded on the processed_source
identity. RuboCop's real CLI builds a fresh cop per file, yet a reused
instance (vendor specs, and any future RuboCop change to instance reuse)
investigates several sources in turn. A plain @bundle_eligible /
.nil? / defined? memo would freeze the first file's verdict and leak it
onto later files with a different eligibility; keying on the source
identity recomputes it on each new investigation.