Skip to content

c/cpp/java dead_code: count a keyword-led comment only when it has a statement's shape (Part of #7207) - #7307

Merged
squid-shepherd[bot] merged 2 commits into
mainfrom
churn/7207-20261031T1341Z
Oct 31, 2026
Merged

squid-shepherd[bot] merged 2 commits into
mainfrom
churn/7207-20261031T1341Z

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #7207 (slice 2: C family; slice 1 COBOL was #7296).

What

dead_code for c, cpp, java counted any comment that began with a keyword (// if the user cancels, we retry, // return value is ignored, // public API, do not change). A keyword-led comment now counts only when the rest of the line has a statement's shape: it ends in ; { } or a (...) group (optional */), or holds an assignment (=, +=, :=). The existing COMMENTED_STATEMENT_C_FAMILY alternative (#4171) is unchanged. The new helper commented_keyword_statement (in _shared_patterns.py) is bounded by line and 400 chars, so it stays linear (a test pins a 15k-char line). It also gains the (?<![/*]) guard, so a /// doc line (/// return value is the count) no longer matches.

Tests

tests/extraction/languages/test_c_family_dead_code_shape_7207.py: real commented-out positives per language (// if (x) {, /* while (running) { */, // int count = 0;, // import java.util.List;, // std::cout << x;, ...) and 14 prose negatives run on all three. With test_{c,cpp,java}_strict.py: 354 passed.

Golden re-bless

golden-lock.sh crucible_check.py --update --yes (both legs, pins synced, no timeouts in the log). Only dead-code outputs moved (commented_out_code_dead_logic, commented_logic_exposure, and the derived fingerprint/group/snapshot rollups): the drop is the prose comments that no longer count.

Not run: pr_gates --fast / --ratchets (ruff format and ruff check on the changed files are clean; bare ruff reports only S101 on the test, which the per-file config allows).

Class / Sibling gaps

Class: dead_code rules in ;-terminated or brace C-family languages that match a comment marker plus a bare keyword with no check on what follows (#7207). Members handled here: c, cpp, java. The same helper applies to the rest.

Sibling gaps (not here: the 5-file cap, each is a one-line swap plus a test row):

Remaining slices

  1. csharp, typescript, javascript, rust (helper swap + test rows + re-bless).
  2. go, kotlin, swift (semicolon-less shape).

🤖 Generated with Claude Code

@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 13:52
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot enabled auto-merge (squash) October 31, 2026 13:52
@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