Skip to content

ruby: a method's span runs past its end after a regex literal containing a quote #3646

Closed

Description

@squid-protocol

Part of #3641. Shape ruby/call/outside-ts-function, 73 occurrences, validated in docs/self_scan/graph_comparison_ledger.json.

In ruby/rails/generator.rb, extract_anchors (line 233) is followed by check_fragment_identifiers (line 250). The engine lists correct, unescape and first on extract_anchors, but they're called only in check_fragment_identifiers. So extract_anchors's span runs past its end.

Likely trigger: the regex literal /<h\d\s+id="([^"]+)/ on line 236. Its unbalanced " can open a string for the literal shield or the slicer, so the end keywords that follow are hidden until a later " closes it.

Fix direction:

  • Treat Ruby /…/ regex literals (after (, ,, =, .scan, =~, keyword position) as literals in the ruby shield, as JS does.
  • Add a regression test: two methods, the first containing /"/.

The same bug inflates the spans in any Ruby file with quotes inside regexes, which affects calls_out_to, complexity and LOC.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore-engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions