Skip to content

python/shell dead_code: count a # comment only when it has a statement's shape (Part of #7207) - #7335

Merged
squid-shepherd[bot] merged 1 commit into
mainfrom
churn/7207-20261031T1839Z
Oct 31, 2026
Merged

squid-shepherd[bot] merged 1 commit into
mainfrom
churn/7207-20261031T1839Z

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #7207 (slice 4, first half). Follows #7322.

commented_keyword_statement (_shared_patterns.py) gains two optional args: marker (a regex replacing //, here #) and extra (one more shape alternative). python and shell now count a keyword-led # comment only when the rest of the line has a statement's shape.

  • python: (...), an assignment, ;{}, a trailing : (# if x > 3:, # try:), or import a.b [as c]. Prose (# if the user cancels, we retry, # import order matters) no longer counts.
  • shell: ;{}, (...), an assignment, a quote / $ / pipe / redirect / &, a flag ( -rf), a path ( /tmp), or ; then|do. # echo "debug" counts; # echo is slow here does not.
  • test_shell_strict.py: the old positive # echo debug is bare prose-shaped, so it becomes # echo "debug".
  • New test_script_dead_code_shape_7207.py: positives and prose negatives per language, plus a long-line ReDoS bound.

Known losses (a bare command/statement is indistinguishable from prose): python # return x, # import a, b; shell # cd build, # ls.

Goldens

Re-blessed both legs via golden-lock.sh crucible_check.py --update --yes. Full-precision fixture moves in commented-logic/dead-code outputs and the fingerprint derived from them (fewer prose hits); zero-dep fixture rewritten, no content diff beyond the same files. Drift is limited to dead_code consumers.

Gates

pr_gates --fast 9/9 after the import-order fix (lint rerun alone); --ratchets 9 pass, 0 skipped. Strict suites for python and shell: pass.

Class / Sibling gaps

Class: dead_code rules matching a bare comment marker + keyword (prose false positives), #7207. Members done across slices: cobol, c/cpp/java, csharp/typescript/javascript/rust, go/kotlin/swift, and now python and shell.
Remaining slices (same mechanism, marker= / extra=): ruby (#; puts "x", bare def Name; dropped here to keep to 5 hand-written files: shared helper, python, shell, new test, shell_strict), perl (#, my|our|sub|...), php (//, #, /*; the //\s*[;{}] and echo|print|$|return|var_dump alternatives), lua (--, --[[). Each: rule + prose/positive test + golden re-bless.
Sibling gaps: the other ~35 languages from the issue's probe list (abap, ada, apex, dart, fortran, groovy, haskell, matlab, rexx, tcl, ...) remain, same mechanism with their own markers.

Lessons for agents

  • ls ~/.cache/gitgalaxy/ruff-*/bin/ruff matches several pinned versions; read the pin from ci/requirements/lint.in and use ruff-<ver>/bin/ruff. Bare ruff check shows 66 unrelated errors; use pr_gates --fast --only lint.

Cross-repo: none.

🤖 Generated with Claude Code

…ent's shape (Part of #7207)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@squid-protocol squid-protocol added the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Oct 31, 2026
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot marked this pull request as ready for review October 31, 2026 18:58
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant