Skip to content

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

Closed

Description

@squid-protocol

Problem

Java's dead_code rule (gitgalaxy/standards/language_standards/languages/java.py:341) only matches a commented-out line that starts with a keyword:

//[ \t]*(?:public|private|protected|class|void|if|for|while|return|import)\b

It misses commented-out statements, calls, assignments and declarations. Example: IBM WCA4Z's published Lgacdb01.java (sandeephans/validation-c2j @ 967d00b) has 11 such lines, and they hold the dropped behaviour:

// ps.setDate(4, caCustomerRequest.getGenasa1Customer().getDateofbirth());
// caReturnCode = 90;
// errorMsg.writeErrorMessage();
// CaCustomerRequest caCustomerRequest = new CaCustomerRequest();

The file scans with state_graveyard = 0 and risk_dead_code = 0, although risk_tech_debt reads 84.

Why it matters

In machine-translated code, commented-out lines are often exactly where the translator gave up. A scanner that reports them would point reviewers straight at the dropped behaviour.

Suggested direction

Match commented lines that parse as a Java statement: assignment, call, declaration, or a statement ending in ;. Use negative cases so prose comments don't count. Then check the other C-family dead_code rules for the same gap.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope:frontierMapped, not yet built: eras/commands/regions the burned estates don't use (Gap Atlas)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions