Skip to content

Java/C# explicit_casts: a parenthesised capitalised condition (if (DEBUG) log(x);) counts as a cast #9424

Backlog

Description

@squid-protocol

Found by the SOP-002 gap-cell decoy suite (protocol SOP-002-v1, epic #8863).

Construct: a parenthesised capitalised identifier followed by a statement, i.e. the condition of an if / while with no braces. The explicit_casts rule reads (Name) x as a cast to type Name.

Snippets (each should give 0 explicit_casts):

  • Java: if (DEBUG) log(x);, while (RUNNING) tick();, if (Ready) go();
  • C#: if (IsReady) Run();, if (DEBUG) Log();

Expected: 0 hits. A parenthesised condition is not a conversion (contract: "a cast expression, a conversion call or a cast keyword", signal_contracts.py). Actual: 1 hit each. PascalCase properties and UPPER_CASE constants in single-statement conditions are common in both languages.

Rules: gitgalaxy/standards/language_standards/languages/java.py (explicit_casts: \(\s*(?:...|[A-Z][A-Za-z0-9_]*)\s*\)\s*[a-zA-Z_$]) and csharp.py (same shape, second branch).

Locked in tests/decoys/test_decoy_java.py and tests/decoys/test_decoy_csharp.py as xfail(strict=True).

Activity

  1. added
    bug
    on Nov 26, 2026
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions