Skip to content

xtask(check-static-language): make violations actionable (file:line + snippet + fix hint) - #1106

Merged
EffortlessSteven merged 1 commit into
mainfrom
feat/static-language-actionable-feedback
Jun 11, 2026
Merged

EffortlessSteven merged 1 commit into
mainfrom
feat/static-language-actionable-feedback

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

What

check-static-language reported only path: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:

policy/dependency_allowlist.txt:36 prohibited static-language term `proven` in
`# note: this dependency set is proven` — this gate scans all tracked prose, not
just analyzer output. In output, use the approved exposure vocabulary
(exposed/weakly_exposed/reachable_unrevealed/...). In comments or docs, use a
plain synonym (e.g. demonstrated/established).

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

  • Extracted static_language_violation_message + static_language_synonym_hint as testable helpers; added unit tests (message shape + snippet truncation) — 2 pass.
  • Behavioral repro (planted a forbidden term in a non-exempt .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

… 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).
@coderabbitai

coderabbitai Bot commented Jun 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7bbffe26-226e-48ec-9804-59148acaeef8

📥 Commits

Reviewing files that changed from the base of the PR and between e250aa5 and 37a0255.

📒 Files selected for processing (1)
  • xtask/src/main.rs

Summary by CodeRabbit

  • Improvements

    • Violation messages now display in a clearer format with suggested alternative terms for prohibited language.
    • Enhanced message clarity with automatic truncation of long code snippets.
  • Tests

    • Added comprehensive tests for violation message generation and formatting.

Walkthrough

This pull request centralizes static-language term violation message construction. A new static_language_violation_message builder function formats actionable report strings with path:line prefixes, term mentions, truncated snippets, and synonym-based remediation hints via a companion static_language_synonym_hint function. Unit tests validate message composition and truncation behavior.

Changes

Static-language violation message formatting

Layer / File(s) Summary
Violation message helper functions
xtask/src/main.rs
static_language_synonym_hint maps prohibited terms (e.g., "proven") to suggested neutral prose alternatives (e.g., "demonstrated/established"), and static_language_violation_message constructs the complete report string with path:line, the term, a truncated snippet bounded to avoid long lines, and a prose-vs-output remediation hint using the mapped synonym.
Integration at call site and exports
xtask/src/main.rs
The violation reporting call site now invokes static_language_violation_message instead of building the report inline, and the new function is added to the module's public exports.
Unit test coverage
xtask/src/main.rs
Two new tests validate that the generated violation message is actionable and contains the expected components (prefix, term, snippet, prose-scope explanation, and mapped synonym), and that long input lines are truncated with an ellipsis while still providing the correct synonym hint.

🎯 2 (Simple) | ⏱️ ~10 minutes

🐰 A helper hops in with prose,

To guide the words we ought not use,

With "proven" → "shown" in fuzzy rows,

No more shall violations cause confuse!

Tests twitch to check the snippets trim. 📋✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: enriching static-language violations with file:line prefix, code snippet, and fix hint to make them actionable.
Description check ✅ Passed The description covers the what, why (implicit context cost fix time), the change with before/after examples, and verification steps including unit tests and behavioral repro.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/static-language-actionable-feedback

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.rs

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 and usage tips.

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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".

Comment thread xtask/src/main.rs
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 \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment thread xtask/src/main.rs
) -> String {
let trimmed = line.trim();
let snippet = if trimmed.chars().count() > 80 {
let mut shortened: String = trimmed.chars().take(77).collect();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.27273% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
xtask/src/main.rs 87.27% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

@EffortlessSteven
EffortlessSteven merged commit d15a894 into main Jun 11, 2026
22 of 25 checks passed
@EffortlessSteven
EffortlessSteven deleted the feat/static-language-actionable-feedback branch June 11, 2026 20:06
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