Issue #11103: Fix Indentation check for lambda in enum constant argum…#18687
Conversation
|
Github, generate report for Indentation/all-examples-in-one |
016e96a to
3fd9df1
Compare
|
Report for Indentation/all-examples-in-one: |
|
Investigating the cases |
|
Hi @romani For example, the new violation in https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/016e96a76d3ef484bf86b85a78df95e7cb1034fd_2026143035/reports/diff/openjdk25/index.html#A1: The lambda () -> { appears inline after OptionCategories.PROPERTY which starts at column 16. Therefore, the lambda body should be at 16+4=20, but it's at column 12. This is genuinely incorrect indentation that was being overlooked before. The current fix uses ENUM_CONSTANT_DEF as the base, which calculates expected body indentation as 16 (enum constant 8 + lineWrapping 4 + basicOffset 4). For inline lambdas, this is slightly lower than the visually ideal 20. However, with forceStrictCondition=false (default), both 16 and 20 are acceptable. Once we align on this fix and confirm there are no false positives, I can explore adding stricter handling for inline lambdas as a follow up enhancement. Please review the diff report and let me know if any of the newly flagged violations appear to be false positives or if I am missing something. |
|
Additionally, the fix also resolves false positives for correctly indented code. Result on master (without fix): However, this code Is correctly indented:
This example shows that the original code produces false positives for block lambdas with statements in enum constants. |
|
Please trigger diff test on all examples config |
|
@romani I have already triggered Github, generate report for Indentation/all-examples-in-one. Could you please clarify which specific config you'd like me to test with? Is there a different command I should use? |
|
@romani ping |
romani
left a comment
There was a problem hiding this comment.
looks good, I did not notice diff report, all good.
thanks a lot.
fixes #11103
fixes #13539
Added handling in
LambdaHandler.getIndentImpl()to detect lambdas inside enum constant arguments and calculate their expected indentation based on the enum constant's position.