Skip to content

dead_code: count commented-out statements in the ;-terminated C-family languages - #4211

Merged
squid-protocol merged 2 commits into
mainfrom
fix/java-commented-out-code
Oct 3, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
fix/java-commented-out-code

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Fixes #4171.

The gap. dead_code only 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 published Lgacdb01.java has 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_FAMILY in _shared_patterns.py, matches one line after // or /* (never a /// or /** doc line) holding one of the following and ending in ;:

  • a call;
  • an assignment (not a comparison);
  • a declaration (a capitalised type needs an initializer).

Prose such as // Load data;, // Note that a = b; and // e.g. x == y; doesn't count.

Languages.

  • Applied: java, c, cpp, csharp, javascript, typescript, dart, rust.
  • Not applied: kotlin, go, swift, scala and groovy, which have no statement terminator to anchor on and keep their keyword rule.
  • Contract: 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/extraction and tests/core_engine: 11,081 passed. ruff_audit --ci and signal_contract_audit --ci clean.

Golden masters. Re-blessed in both modes via crucible_check.py --update --yes, after auditing main against this branch on the crucible:

  • Only state_graveyard / fam_dead_code moved, in 22 of 3,256 files, all in the touched languages.
  • Every new hit is real commented-out code, e.g. cpython /* a.update(a) …;, Doom //exit(1);, sqlite /* assert( stp->ap );, Godot // _gdtype_ptr = nullptr;, Roslyn // Console.WriteLine();, three.js // _gl.finish();.
  • The rest of the fixture diff is that change re-normalised across the repo.

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

squid-protocol and others added 2 commits October 3, 2026 04:18
…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
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 1705916 into main Oct 3, 2026
38 checks passed
@squid-protocol
squid-protocol deleted the fix/java-commented-out-code branch October 3, 2026 10:03
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.

java dead_code: commented-out statements that don't start with a keyword go uncounted

1 participant