Robin Malfait 25f7ccff80
Fix class extraction for Rails' strict locals (#19525)
Fixes: #19481

This PR improves the Ruby extractor to better handle strict locals. We
recently introduced skipping comments in the Ruby extractor (PR #19243
for #19239) by ignoring comments that start with `#` until the end of
the line.

Strict locals are implemented like this:
```ruby
<%# locals: (css: "text-amber-600") %>
```

Notice the `#` after the `<%`, we considered this a comment and ignored
it.

This PR changes that behavior slightly where we skip comments that are
preceded by `%`. This means that `<%# anything here _will_ be scanned
%>`. This should solve the strict locals case, and normal comments will
still be skipped.

We can be more strict in the future if needed, but I think that this
should be a good solution for both scenarios.

### Test plan

1. Added a test to ensure we extract candidates in strict locals
2. Added a regression test for issue #19239 where we introduced skipping
comments in the Ruby extractor
3. Other existing tests are still passing

We can also verify the extracted candidates:
(it's subtle, but you can see that the class is being extracted now)

<img width="1187" height="1376" alt="image"
src="https://github.com/user-attachments/assets/74bbfd79-9db4-4a5b-bd8d-25f1565c6bfd"
/>
2026-01-06 12:46:14 +01:00
..