Skip to content

feat: detect Go and Rust during init#34

Merged
DataDave-Dev merged 3 commits into
DataDave-Dev:mainfrom
sarkarshrayan2-max:add-go-rust-init-detection
Jun 30, 2026
Merged

feat: detect Go and Rust during init#34
DataDave-Dev merged 3 commits into
DataDave-Dev:mainfrom
sarkarshrayan2-max:add-go-rust-init-detection

Conversation

@sarkarshrayan2-max

@sarkarshrayan2-max sarkarshrayan2-max commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

What

Add Go and Rust support to becwright init.

  • Detect .go files as Go and .rs files as Rust
  • Generate Go/Rust source globs for starter rules
  • Add the existing no-debug-go and no-debug-rust starter rules
  • Add focused tests for pure-Go and pure-Rust repositories

Why

becwright init previously detected only Python, JavaScript, and TypeScript. A repository containing only Go or Rust files generated no starter rules.

This change keeps init consistent with the existing importable Go and Rust catalog BECs.

Checklist

  • Tests pass (pytest)
    Full suite on Windows: 124 passed, 5 failed. The five failures were present before this change and are related to Windows shell command handling.
  • New behavior is covered by tests
  • Commits are atomic (one logical change each)
  • Docs updated if needed — not needed for this internal init-scaffolding change

Summary by CodeRabbit

  • New Features
    • Project initialization now recognizes Go and Rust source files in addition to existing languages.
    • Starter configuration now includes language-specific checks for Go and Rust to help catch unsafe debug output patterns.
  • Tests
    • Expanded coverage for language detection, starter rule generation, and YAML output to verify Go and Rust support works as expected.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 53 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: e8843c90-0db0-427e-8b2d-5cfef9e77c67

📥 Commits

Reviewing files that changed from the base of the PR and between df839fc and 1401084.

📒 Files selected for processing (2)
  • src/becwright/cli.py
  • tests/test_init.py
📝 Walkthrough

Walkthrough

The CLI's init scaffolding now detects Go and Rust source files alongside Python/JS/TS, generating corresponding starter rules. New blocking rules forbid Go panic/debug output and Rust debug macros. Tests cover detection, rule generation, and YAML rendering/round-trip for both languages.

Changes

Go/Rust Starter Rule Scaffolding

Layer / File(s) Summary
Language detection and starter rule generation
src/becwright/cli.py
Extension map and _detect_languages now recognize .go and .rs; _starter_rules adds glob coverage and new blocking rules forbidding Go panic/debug output and Rust debug macros/println-like calls.
Detection and rule tests
tests/test_init.py
New tests verify Go/Rust detection, starter rule IDs/globs/blocking config, and successful YAML render/reload producing no-hardcoded-secrets, no-debug-go, and no-debug-rust rules.

Sequence Diagram(s)

Skipped — this change is a straightforward extension of existing CLI scaffolding logic with no new multi-component interaction flow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Possibly related PRs

  • DataDave-Dev/becwright#6: Original init implementation with language detection and starter-rule generation that this PR extends.
  • DataDave-Dev/becwright#15: Adds matching no-debug-go/no-debug-rust forbid rule bundles referenced by the new starter rules.

Poem

A hop, a skip, a Go-fer's delight,
Rust macros caught in panic's light. 🐇
No more println left to roam,
Starter rules now call them home.
Carrots compiled, tests all green—
The tidiest burrow you've ever seen!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding Go and Rust detection during init.
Description check ✅ Passed The description matches the template with clear What, Why, and Checklist sections and includes testing and coverage notes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@sarkarshrayan2-max

Copy link
Copy Markdown
Contributor Author

Thanks! I’ve implemented the Go/Rust detection and starter rules by mirroring the existing catalog BECs, including their patterns, intent/why text, and blocking severity. I also added focused language-detection and starter-rule tests for Go and Rust. I’ll open the PR against main.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/becwright/cli.py (1)

213-225: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Consider word boundaries on the Go/Rust forbid patterns for consistency.

The existing JS rule uses \bdebugger\b to avoid matching debugger as a substring of a longer identifier. The new Go (panic\s*\() and Rust (dbg!\s*\(, println!\s*\() patterns lack equivalent boundaries, so identifiers like mypanic( or myeprintln!( could trigger false positives since the pattern is a substring search, not anchored.

This is a minor false-positive risk rather than a functional bug, since forbid-based checks already operate on raw line text.

♻️ Optional fix for tighter matching
-            check=r"becwright run forbid --pattern 'fmt\.Println\s*\(|panic\s*\('",
+            check=r"becwright run forbid --pattern '\bfmt\.Println\s*\(|\bpanic\s*\('",
-            check=r"becwright run forbid --pattern 'dbg!\s*\(|println!\s*\('",
+            check=r"becwright run forbid --pattern '\bdbg!\s*\(|\bprintln!\s*\('",

Note: changing these literal check strings would also require updating the corresponding assertions in tests/test_init.py (test_starter_rules_go, test_starter_rules_rust).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/becwright/cli.py` around lines 213 - 225, The Go and Rust forbid patterns
in the starter rules are overly broad and can match substrings inside longer
identifiers. Update the `no-debug-go` and `no-debug-rust` rule definitions in
`cli.py` to use tighter matching with word-boundary style anchoring or
equivalent pattern constraints around the debug/panic tokens, while keeping the
intent of forbidding `fmt.Println`, `panic`, `dbg!`, and `println!`. Make sure
the corresponding expectations in `tests/test_init.py` (`test_starter_rules_go`,
`test_starter_rules_rust`) are updated to match the revised `check` strings.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/becwright/cli.py`:
- Around line 213-225: The Go and Rust forbid patterns in the starter rules are
overly broad and can match substrings inside longer identifiers. Update the
`no-debug-go` and `no-debug-rust` rule definitions in `cli.py` to use tighter
matching with word-boundary style anchoring or equivalent pattern constraints
around the debug/panic tokens, while keeping the intent of forbidding
`fmt.Println`, `panic`, `dbg!`, and `println!`. Make sure the corresponding
expectations in `tests/test_init.py` (`test_starter_rules_go`,
`test_starter_rules_rust`) are updated to match the revised `check` strings.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4b3b34ef-6657-40d8-a59a-4acfc636d465

📥 Commits

Reviewing files that changed from the base of the PR and between fcf940b and df839fc.

📒 Files selected for processing (2)
  • src/becwright/cli.py
  • tests/test_init.py

@DataDave-Dev

Copy link
Copy Markdown
Owner

Pulled this down and ran it through its paces — really nice work. 🙌

I spun up throwaway Go, Rust, mixed, and pure-Python repos and becwright init did the right thing in every one: Go-only gets no-debug-go, Rust-only gets no-debug-rust, and a mixed repo stacks them all without stepping on each other. Then I committed actual violations — fmt.Println in Go, println!/dbg! in Rust — and both got blocked, while clean files sailed through. So it's not just wiring up detection, the generated rules genuinely do their job end to end. Full suite is green here too (the Windows failures you flagged are pre-existing and unrelated to your change — don't sweat those).

The tests are the part I appreciated most: you covered detection, rule generation, and that the YAML actually parses back. That's exactly the kind of thoroughness that makes a PR easy to trust.

Thanks for picking this up and seeing it through — this is a real, useful addition and it's landing cleanly. Hope it's the first of many. 🚀

@DataDave-Dev
DataDave-Dev merged commit 605a3b6 into DataDave-Dev:main Jun 30, 2026
1 check passed
@sarkarshrayan2-max

sarkarshrayan2-max commented Jun 30, 2026 via email

Copy link
Copy Markdown
Contributor Author

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.

2 participants