Skip to content

Fix the indentation the checkstyle auto-fix gets wrong - #9178

Merged
reiabreu merged 1 commit into
apache:masterfrom
sercuzz8:checkstyle-autofix-indentation
Oct 19, 2026
Merged

reiabreu merged 1 commit into
apache:masterfrom
sercuzz8:checkstyle-autofix-indentation

Conversation

@sercuzz8

Copy link
Copy Markdown
Contributor

OpenRewrite's TabsAndIndents re-indent pass puts array initializer elements at the
continuation indent and misplaces the bodies of some anonymous classes and enum constants.
Checkstyle's Indentation check rejects these as errors, so the auto-fix of storm-client
(run on my fork) went from 0 to 27 errors and failed mvn validate.
The other warnings stayed the same or decreased, depending on their category.

Changes

  • Replace the OpenRewrite re-indent pass (checkstyle-reindent-openrewrite) with a Groovy
    pass (checkstyle-autofix-indentation) that runs checkstyle-autofix.groovy with only new
    Indentation and CommentsIndentation fixers. These move each reported line (plus the rest
    of a reported declaration header, or a whole block comment) to the level Checkstyle expects.
  • Update the workflow, root pom, rewrite.yml and storm-checkstyle/README.md to match.

The auto-fix still runs three passes.

Testing

Tested locally on storm-client, starting from a copy that has not been auto-fixed:

Before (sercuzz8#2) After
Errors 27 Indentation 0
mvn validate -pl storm-client fails passes
Warnings 7,223 7,149

Warnings per check, before the run (master) and after it (this PR's tooling):

Check Before After
LineLength 8,227 4,345
MissingJavadocMethod 2,020 2,020
MissingJavadocType 624 624
MatchXpathCheck#singleLineCommentStartWithSpace 369 0
EmptyLineSeparator 199 12
RequireEmptyLineBeforeBlockTagGroup 125 0
SummaryJavadoc 114 11
AbbreviationAsWordInName 110 110
JavadocParagraph 73 1
CustomImportOrder 30 0
MethodName 19 19
VariableDeclarationUsageDistance 7 7
Total 11,917 7,149
  • Compared with the output of the old tooling, the only differences are whitespace
    (diff -r -w -B is empty).
  • Not yet tested: other modules, the updated workflow running on GitHub Actions, and
    compiling or running tests.

To reproduce:

mvn install -DskipTests -Dcheckstyle.skip=true -pl storm-client -am
mvn -pl storm-client -Dcheckstyle.skip=true \
  org.openrewrite.maven:rewrite-maven-plugin:run@checkstyle-autofix-openrewrite \
  org.codehaus.gmavenplus:gmavenplus-plugin:execute@checkstyle-autofix \
  org.codehaus.gmavenplus:gmavenplus-plugin:execute@checkstyle-autofix-indentation
mvn validate -pl storm-client

Known leftover

The closing }, of the SUPERVISOR enum constant in DaemonType.java stays at column 0.
Checkstyle doesn't flag it.

🤖 Generated with Claude Code, revised by humans

OpenRewrite's TabsAndIndents re-indent pass puts array initializer elements at the
continuation indent and misplaces the bodies of some anonymous classes and enum constants,
which Checkstyle's Indentation check rejects (27 errors on storm-client). Replace that pass
with the checkstyle-autofix-indentation execution, which runs the Groovy stage again with only
new Indentation and CommentsIndentation fixers. They move each reported line (and the rest of
a reported declaration header, or a whole block comment) to the level Checkstyle's message
expects. The auto-fix still runs three passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rzo1
rzo1 requested a review from GGraziadei October 18, 2026 18:52
@reiabreu reiabreu added this to the 3.2.0 milestone Oct 19, 2026
@reiabreu
reiabreu merged commit 3e933c5 into apache:master Oct 19, 2026
7 checks passed
@sercuzz8
sercuzz8 deleted the checkstyle-autofix-indentation branch October 19, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants