Skip to content

Issue #17663: Fixing False negatives (indentation)#18784

Open
aclfe wants to merge 1 commit intocheckstyle:masterfrom
aclfe:indent-fix
Open

Issue #17663: Fixing False negatives (indentation)#18784
aclfe wants to merge 1 commit intocheckstyle:masterfrom
aclfe:indent-fix

Conversation

@aclfe
Copy link
Contributor

@aclfe aclfe commented Jan 28, 2026

Issue #17663: Fixing False negatives (indentation)

In the original issue #17663, there were 2 false negatives. One was with arrow lambda expression as such

  java.util.function.Function<String, Integer> test_arrow() {
    return (String s) ->
    s.length(); // Expected Violation (but ignored)
  }

the other one was with MethodCallHandler:

  int test_comma() {
    return sum(
    1, // Expected Violation (but ignored)
    2, // Expected Violation (but ignored)
    3  // Expected Violation (but ignored)
    );

Both false negatives have been addressed in the changes

@aclfe aclfe changed the title Issue #17663: WIP Fix false negatives indent Issue #17663: Fixing False negatives (indentation) Jan 29, 2026
@aclfe aclfe marked this pull request as ready for review January 29, 2026 16:20
@aclfe
Copy link
Contributor Author

aclfe commented Jan 29, 2026

@romani

So I did fix for switch expression lambda indentation. I made changes, they're working correctly. But because they're working correctly, now it's catching previously missed violations in external projects like Kafka and PMD that test against checkstyle. The CI jobs are failing since they're catching these errors. Here are examples of where the errors are being thrown on legitimate places:


no-error-xwiki:
[ERROR] src/main/java/org/xwiki/rendering/internal/macro/toc/TocTreeBuilder.java:[260,21] (indentation) Indentation: 'lambda arguments' has incorrect indentation level 20, expected level should be 12.

The actual file itself:
https://github.com/xwiki/xwiki-rendering/blob/340dc7df070ae12a660a8f3fcffb6218257f2de1/xwiki-rendering-macros/xwiki-rendering-macro-toc/src/main/java/org/xwiki/rendering/internal/macro/toc/TocTreeBuilder.java#L257-L263


no-error-pmd:

[ERROR] src/main/java/net/sourceforge/pmd/lang/java/ast/internal/JavaAstUtils.java:[306,37] (indentation) Indentation: 'lambda arguments' has incorrect indentation level 36, expected level should be one of the following: 20, 32. [ERROR] src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/ImplicitMemberSymbols.java:[164,25] (indentation) Indentation: 'lambda arguments' has incorrect indentation level 24, expected level should be one of the following: 16, 20.

The actual files:
https://github.com/pmd/pmd/blob/237f5cfabccb4e46db57b7095d2b07eb99fe93bd/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/JavaAstUtils.java#L303-L308

https://github.com/pmd/pmd/blob/237f5cfabccb4e46db57b7095d2b07eb99fe93bd/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/ImplicitMemberSymbols.java#L159-L166


Kafka has similar violations.
My real question is what should be done in this situation? Should we suppress the violations for external projects?

@vivek-0509 you're an expert with indentation mutation logic, do these look right to you? Since you have the context fresh in your mind, do you think these errors in PMD look like valid violations to you, or is it accidentally too strict?

@romani
Copy link
Member

romani commented Jan 30, 2026

My real question is what should be done in this situation? Should we suppress the violations for external projects?

we should send them fixes by PRs, ideally they can merge it before we finish this PR. If behavior is not compatible, we still create PR, and we can update CI jobs to use your PRs branch to let CI pass on your fixes, and such projects will merge PRs after we release your fix.

@aclfe
Copy link
Contributor Author

aclfe commented Jan 30, 2026

Github, generate report for Indentation/all-examples-in-one

@github-actions
Copy link
Contributor

Failed to parse comment command.

Please ensure you've used one of the valid command formats.

Link: https://github.com/checkstyle/checkstyle/actions/runs/21520419374

@github-actions
Copy link
Contributor

@aclfe
Copy link
Contributor Author

aclfe commented Jan 31, 2026

Report for Indentation/all-examples-in-one: https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/824e186a94604a0f5a43b83359e94e2631409086_2026205550/reports/diff/index.html

The violations are valid. It's interesting, even such a minimal change in MethodCallHandler.java‎ can affect so many return statements. Though it's mostly when <property name="forceStrictCondition" value="true"/>

I'll start sending PRs to the other repos

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.

2 participants

Comments