Skip to content

Remove redundant semicolons (top level, class/enum bodies, statements) #156

Open

Description

@abashev

Upstream: google/google-java-format#1491
Kind: idea | Priority: low

google-java-format#1491 (merged 2026-10-22, copybara export) extends the --cleanup AST pass from google-java-format#1492 so that stray ; are deleted at top level, in class and enum bodies, and as empty statements in blocks. Upstream also moves several existing goldens (for example the semicolon-in-class case) into a "changed by cleanup" set.

Why it matters: our formatter keeps these semicolons, e.g. our golden SemicolonInClass still outputs a lone ; inside the class. It is a harmless tidy-up with a small footprint, but like brace insertion it is a non-whitespace rewrite and should only come with an opt-out.

Examples: not available - the diff shows only the removal of the ;, not the resulting layout of the emptied body in our formatter; our current output keeps the lone ; as in the golden above.

Affected files in our repo:

  • open-java-format/src/main/java/com/palantir/javaformat/java/JavaInputAstVisitor.java (visitEmptyStatement, class body member handling)
  • open-java-format/src/test/resources/com/palantir/javaformat/java/testdata/SemicolonInClass.input and .output

Suggested action: watch / adopt-the-idea together with the brace-insertion ticket; low priority on its own.


Filed from an upstream-watch ticket after manual review.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions