Repository navigation
dead_code: count commented-out statements in the ;-terminated C-family languages - #4211
Merged
Merged
Conversation
…y languages #4171. dead_code only matched a commented line led by a keyword, so commented-out calls, assignments and declarations didn't count -- in machine-translated code often exactly where a translator gave up (IBM WCA4Z's Lgacdb01.java: 11 such lines, read 0, now 11). A shared fragment (COMMENTED_STATEMENT_C_FAMILY) matches one line after // or /* (never a /// or /** doc line) holding a call, an assignment (not a comparison) or a declaration, ending in ';'. Applied to java, c, cpp, csharp, javascript, typescript, dart and rust; kotlin/go/swift/scala/ groovy have no statement terminator and keep their keyword rule. docs/dead_code_rule_contract.md states it. Golden masters re-blessed (both modes) after auditing main vs this branch on the crucible: only state_graveyard / fam_dead_code moved, in 22 of 3,256 files, all in the touched languages, and every new hit is commented-out code (cpython, doom, sqlite, godot, roslyn, three.js, ...); the rest of the fixture diff is that change re-normalised across the repo. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ
Contributor
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.
Fixes #4171.
The gap.
dead_codeonly matched a commented line led by a keyword (// public …,// if (…)). Commented-out calls, assignments and declarations didn't count. In machine-translated code those are often exactly where a translator gave up. IBM WCA4Z's publishedLgacdb01.javahas 11 such lines (the dropped DOB binding and error path among them): it read 0, now 11.The rule. A shared fragment,
COMMENTED_STATEMENT_C_FAMILYin_shared_patterns.py, matches one line after//or/*(never a///or/**doc line) holding one of the following and ending in;:Prose such as
// Load data;,// Note that a = b;and// e.g. x == y;doesn't count.Languages.
docs/dead_code_rule_contract.md.Tests.
test_dead_code_statements.py(154 tests): commented code and prose cases across the 8 languages, Java declarations, the WCA4Z shape counting once per line, linearity on 20,000-character payloads, the doc-line skip, and;-free languages unchanged.tests/extractionandtests/core_engine: 11,081 passed.ruff_audit --ciandsignal_contract_audit --ciclean.Golden masters. Re-blessed in both modes via
crucible_check.py --update --yes, after auditing main against this branch on the crucible:state_graveyard/fam_dead_codemoved, in 22 of 3,256 files, all in the touched languages./* a.update(a) …;, Doom//exit(1);, sqlite/* assert( stp->ap );, Godot// _gdtype_ptr = nullptr;, Roslyn// Console.WriteLine();, three.js// _gl.finish();.One unrelated timing test (
test_embedded_python_comprehensions_redos_immunity) failed under a load average of about 96, and fails on unmodified main too. It passes when run alone.🤖 Generated with Claude Code
https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ