Skip to content

Analyse the test sources with Checkstyle - #219

Merged
MarkusPaulsen merged 1 commit into
mainfrom
chore/checkstyle-test-sources
Aug 26, 2026
Merged

Analyse the test sources with Checkstyle#219
MarkusPaulsen merged 1 commit into
mainfrom
chore/checkstyle-test-sources

Conversation

@MarkusPaulsen

Copy link
Copy Markdown
Collaborator

Summary

Checkstyle never looked at the test tree either. Turning it on reported 2314 findings, of which 2045 were the naming convention that the CI itself relies on to select matrix cells. That is suppressed for the test tree rather than loosened in the rule; the remaining 83 are fixed.

Linked issues

No linked issues

1. Problem

maven-checkstyle-plugin ran without includeTestSourceDirectory, so the test tree was unchecked. The same gap as the PMD change and the same reason it matters: the harness that decides whether a violation was detected is the code most able to fail quietly.

Turning it on is not a one-line change, because 2045 of the 2314 findings are MethodName firing on names such as test_invokeMethod_success. Those underscores are not cosmetic. The Maven workflow selects matrix cells with -Dtest='...#*MavenWalaAspectJ+*_wala_aspectj', so the convention is what makes the mode matrix work at all.

2. Improvement from the user's perspective

No Improvement from the user's perspective

3. Improvement from the maintainer's perspective

Test sources are checked from now on, without the rule fighting the repository's own test-selection mechanism. MethodName is suppressed for the test tree in a suppressions file rather than relaxed in checkstyle-rules.xml, so main sources keep the strict pattern.

What was left is fixed rather than suppressed: 34 single-statement if, for and else bodies now carry braces, and one redundant public modifier is gone. Braces matter more here than style: the next person to add a second statement under an unbraced if in the harness would silently move it outside the condition.

4. Testing manual

Prerequisites

  1. A checkout of this branch and a JDK.

Steps

Not reproducible from an exercise. This changes the build and the test tree.

  1. Run mvn checkstyle:check.
  2. Run mvn test -Punit-core-tests,coverage.
  3. Run mvn test -Pintegration-core-tests,coverage.
  4. Read .settings/checkstyle-suppressions.xml.

Expected result

Step 1 reports no violations. Step 2 reports 774 tests with no failures. Step 3 reports 319 tests with no failures. Step 4 shows two kinds of entry, the fixture paths and the MethodName suppression, each with its reason.

The brace change was verified to be exactly that and nothing more: with braces stripped from both token streams, every touched file is token-identical to main. A reviewer can repeat that check on any of the five files, or read the diff and confirm that only { and } were added.

Negative case (what must still be rejected)

MethodName must still apply to src/main/java. Confirm by checking that the suppression in .settings/checkstyle-suppressions.xml is scoped to src/test/java, and that checkstyle-rules.xml still contains an unmodified MethodName module.

No conditional may have changed which statements it governs. Confirm by reading the diff of ThrowableUtilsTest.java, CustomConditions.java and TestUserExtension.java.

Modes exercised

No mode-specific behaviour changed.

  • ArchUnit + AspectJ
  • ArchUnit + instrumentation
  • WALA + AspectJ
  • WALA + instrumentation

5. Test case coverage regarding this PR

No production Java code changed

Breaking changes and migration

No breaking changes or migration.

Checklist

  • CI is green, or every remaining failure is explained above.
  • No secrets, tokens or absolute local paths are contained in the diff.

Review progress

  • Code review
  • Manual test

Same gap as the PMD change, same reasoning: the harness deciding whether a violation
was detected was the code nobody checked.

2314 findings, of which 2045 were MethodName firing on names like
test_invokeMethod_success. That convention is not cosmetic, it is the test-selection
mechanism: maven.yml picks matrix cells with -Dtest='...#*_wala_aspectj'. Suppressed
for the test tree rather than loosened in the rule, which would have relaxed main
sources as well. The fixture trees are suppressed for the same reason as in the PMD
change.

What is left is 83 real findings, all fixed: 34 single-statement if/for/else bodies now
carry braces, one redundant public modifier is gone. The brace change was verified to
be exactly that and nothing else: with braces removed from both token streams, every
touched file is token-identical to origin/main.

AstAssertionTest keeps two suppressions. Its locals are named after the supervised test
method they assert about, so LocalVariableName was fighting the same convention as
MethodName, and HideUtilityClassConstructor fires because JUnit sees only static
members on a class whose tests live in @nested inner classes.
@MarkusPaulsen
MarkusPaulsen requested a review from a team August 26, 2026 15:13
@MarkusPaulsen
MarkusPaulsen requested review from a team and krusche as code owners August 26, 2026 15:13
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8ec2a44c-2ef0-4424-ac18-5cf0e8d77f4f


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@MarkusPaulsen
MarkusPaulsen merged commit c669366 into main Aug 26, 2026
1 of 2 checks passed
@MarkusPaulsen
MarkusPaulsen deleted the chore/checkstyle-test-sources branch August 26, 2026 18:37
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.

1 participant