Repository navigation
c/cpp/java dead_code: count a keyword-led comment only when it has a statement's shape (Part of #7207) - #7307
Merged
Merged
Conversation
…statement's shape (Part of #7207) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Contributor
|
No description provided. |
Contributor
|
No description provided. |
Contributor
This was referenced Oct 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #7207 (slice 2: C family; slice 1 COBOL was #7296).
What
dead_codefor 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 existingCOMMENTED_STATEMENT_C_FAMILYalternative (#4171) is unchanged. The new helpercommented_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. Withtest_{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_coderules 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):
public|private|...|using), typescript, javascript (//only), rust, dart: keyword alt then+ COMMENTED_STATEMENT_C_FAMILY; swap the keyword alt forcommented_keyword_statement(...).;; the helper applies (block=False), but bare// return nil, err/// var x inthave no shape and need a per-language shape for semicolon-less statements (decide before swapping).Remaining slices
🤖 Generated with Claude Code