Skip to content

fix(init): don't read a per-function line count as a per-file cap#61

Merged
DataDave-Dev merged 1 commit into
mainfrom
fix-claude-md-line-cap
Jul 2, 2026
Merged

fix(init): don't read a per-function line count as a per-file cap#61
DataDave-Dev merged 1 commit into
mainfrom
fix-claude-md-line-cap

Conversation

@DataDave-Dev

Copy link
Copy Markdown
Owner

What & why

Surfaced while field-testing becwright against real repositories (the last open item on the path to 1.0.0). Running becwright init --from-claude-md on a real Python project (bot-telegram) derived a max-file-lines rule of --max 50, which flagged nearly every file in the repo.

Root cause: the project's CLAUDE.md said, as soft guidance, "~50 líneas por función, ~800 por archivo" ("~50 lines per function, ~800 per file"). The file-cap regex's gap between the number and the file word ([^.\n]{0,25}?) was permissive enough to bridge across the comma and the 800, so it captured the function's 50 and turned it into a per-file cap.

Fix

Exclude commas and digits from that gap ([^.,\n\d]) in both alternatives of _FILE_LINE_CAP, so a match can't cross a clause boundary. For this comma-joined, elliptical phrasing the file number (800) has no lines word of its own, so becwright now derives no cap rather than a wrong one — the conservative, correct outcome for an ambiguous soft guideline (the derivation already leaves judgment calls to CLAUDE.md).

Unchanged, still-passing cases: "files under 800 lines", "Máximo 300 líneas por archivo", "800 lines per file", function-only phrasings (→ none), out-of-range caps (→ none).

Field test results (this closes the "validate on real repos" item)

Repo Language Scenario Result
expertgroup-bi TS/TSX (1117 files, real adopter) check --all read-only, 16 rules Clean, no crash/timeout, rules fired correctly
bot-telegram Python + CLAUDE.md init --from-claude-md Found this bug; now derives 3 clean rules
la-velada-web-oficial TS/Astro, no CLAUDE.md generic init + check --all Clean starter rules; correctly caught a hardcoded secret

Originals were never modified — Python/JS repos were tested in throwaway clones; the TS adopter was check-only (read-only).

Test plan

  • Regression test for the EN + ES phrasing (test_max_lines_cap_does_not_bridge_function_cap_to_file_word).
  • pytest — 252 passing.
  • Re-ran the field test with the fix: bot-telegram derives 3 clean rules, no bogus max 50.

--from-claude-md derived max_lines --max 50 from phrasing like '~50 lines
per function, ~800 per file': the file-cap regex let the gap between the
number and the file word bridge across the comma and the 800, capturing the
function's 50 and then flagging nearly every file. Exclude commas and digits
from that gap so a match can't cross a clause boundary; an ambiguous
comma-joined guideline now derives no cap instead of a wrong one.

Surfaced field-testing becwright against a real Python repo (bot-telegram).
Regression test covers the EN and ES phrasings.
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@DataDave-Dev, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 44 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7cf2b110-e91c-4c33-9174-3e4510290b2c

📥 Commits

Reviewing files that changed from the base of the PR and between 0e3a06e and d34c8c1.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/becwright/cli.py
  • tests/test_init.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-claude-md-line-cap

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@DataDave-Dev DataDave-Dev merged commit 0536496 into main Jul 2, 2026
5 checks passed
@DataDave-Dev DataDave-Dev deleted the fix-claude-md-line-cap branch July 2, 2026 17:06
@DataDave-Dev DataDave-Dev mentioned this pull request Jul 2, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant