Repository navigation
xtask(check-static-language): make violations actionable (file:line + snippet + fix hint) - #1106
Conversation
… snippet + fix hint) The gate reported only `path:line contains prohibited static-language term \`X\``, which left two things implicit that repeatedly cost fix time: (1) WHERE in the line / what context, and (2) that the gate scans ALL tracked prose (comments, policy reasons, non-docs YAML/txt), not just analyzer output — so a hit is often an innocent English word in a comment that just needs a synonym, not an output-vocabulary rewrite. Enrich the message to include the offending snippet and a fix hint naming both paths: in output use the approved exposure vocabulary; in prose use a plain synonym (per-term, e.g. proven -> demonstrated/established, adequate -> sufficient/enough). Pure feedback change — the pass/fail logic and the forbidden term set are unchanged; no new suppression affordance (that was offered separately and is held for sign-off). Extracted `static_language_violation_message` + `static_language_synonym_hint` as testable helpers; added unit tests for the message shape and snippet truncation. Verified end-to-end (planted term -> enriched report line) and via the policy-checker facade (full gate set still green on the clean tree).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
Summary by CodeRabbit
WalkthroughThis pull request centralizes static-language term violation message construction. A new ChangesStatic-language violation message formatting
🎯 2 (Simple) | ⏱️ ~10 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ast-grep (0.43.0)xtask/src/main.rsThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 37a0255397
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let hint = static_language_synonym_hint(term); | ||
| format!( | ||
| "{path}:{line_number} prohibited static-language term `{term}` in `{snippet}` \ | ||
| — this gate scans all tracked prose, not just analyzer output. In output, use the \ |
There was a problem hiding this comment.
Describe the actual working-tree scan scope
Failure mode: when check-static-language fails because of an untracked scratch .md, .rs, .toml, etc., the new hint says the gate scans “tracked prose,” but check_static_language_impl still walks collect_files(Path::new(".")), so untracked candidate files are included too. Why here: this feedback is meant to make remediation actionable, and the false scope can send a follow-up agent toward allowlisting or rewriting tracked files instead of removing/ignoring the local untracked file. Fix direction: either change the hint to “working-tree prose/files” or make the check use tracked_files() if tracked-only is intended; validate with cargo xtask check-static-language plus a small test/repro for an untracked candidate file.
Useful? React with 👍 / 👎.
| ) -> String { | ||
| let trimmed = line.trim(); | ||
| let snippet = if trimmed.chars().count() > 80 { | ||
| let mut shortened: String = trimmed.chars().take(77).collect(); |
There was a problem hiding this comment.
Center long snippets on the offending term
Failure mode: for long candidate lines where the prohibited word appears after the first 80 characters, this truncation reports only the line prefix and an ellipsis, so the new “offending snippet” often does not contain the offending text or nearby context; this is especially plausible for scanned JSON/YAML/TOML lines. Why here: the commit’s purpose is actionable file:line + snippet feedback. Fix direction: pass or compute the match offset and build a bounded window around the matched term instead of always taking the first 77 chars; validate with a test where adequate/proven occurs past column 80 and the emitted snippet still includes it.
Useful? React with 👍 / 👎.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
What
check-static-languagereported onlypath:line contains prohibited static-language term \X``. That left two things implicit that repeatedly cost fix time (it bit me twice this week): where/what context in the line, and that the gate scans all tracked prose (comments, policy-file reasons, non-docs YAML/txt) — not just analyzer output. So a hit is often an innocent English word in a comment that needs a plain synonym, not an output-vocabulary rewrite.Change (feedback only)
Enriched the violation to include the offending snippet and a fix hint naming both paths:
Before:
policy/workflow_allowlist.txt:21 contains prohibited static-language term \proven``After:
Pure feedback change — pass/fail logic and the forbidden-term set are unchanged. No new suppression affordance (that was offered separately and is held for sign-off, since it changes contributor-facing policy). The broad-scan-vs-output-only scope question is likewise left to you.
Verified
static_language_violation_message+static_language_synonym_hintas testable helpers; added unit tests (message shape + snippet truncation) — 2 pass..txt→ the enriched report line above).policy_checker_facade_runs_current_repo_checks(the full CI gate mirror) green on the clean tree; fmt + clippy green.This is improvement #1 from the gate review you asked about. #2 (line-level inline allow) and the scope decision remain yours to call.
🤖 Generated with Claude Code