Issue #21160: Add indentation support for module declarations - #21280
Issue #21160: Add indentation support for module declarations#21280sahitya0xsingh wants to merge 1 commit into
Conversation
f47f59e to
9a68e36
Compare
|
@vivek-0509 , please help to review . |
| PROP_CS_VERSION="checkstyleVersion" | ||
| REQ="java.util.Objects.requireNonNull" | ||
| JMS_PATH="spring-integration-jms/src/main/java/org/springframework/integration/jms" | ||
| sed -i'' "s/withPayload(converted)/withPayload($REQ(converted))/" \ | ||
| $JMS_PATH/channel/AbstractJmsChannel.java | ||
| sed -i'' "s/withPayload(object)/withPayload($REQ(object))/" \ | ||
| $JMS_PATH/inbound/JmsDestinationPollingSource.java | ||
| sed -i'' "s/withPayload(result)/withPayload($REQ(result))/" \ | ||
| $JMS_PATH/outbound/JmsOutboundGateway.java | ||
| sed -i'' "s/withPayload(result)/withPayload($REQ(result))/" \ |
There was a problem hiding this comment.
Done. Thanks!
|
please rebase the pr |
fcff972 to
9cb28f1
Compare
|
Rebased. Ready for review. Thanks! |
| register(TokenTypes.OBJBLOCK, ObjectBlockHandler.class); | ||
| register(TokenTypes.INTERFACE_DEF, ClassDefHandler.class); | ||
| register(TokenTypes.IMPORT, ImportHandler.class); | ||
| register(TokenTypes.MODULE_DEF, ClassDefHandler.class); |
There was a problem hiding this comment.
Reusing ClassDefHandler for MODULE_DEF gives wrong violation text. getHandlerName has no MODULE_DEF case and falls into default -> "interface def".
Reproduced on this branch
module com.example.app {
requires java.base;
}
1:5: 'interface def ident' has incorrect indentation level 4, expected level should be 0.
3:5: 'interface def rcurly' has incorrect indentation level 4, expected level should be 0.
Please add a dedicated handler for MODULE_DEF and leave ClassDefHandler untouched, the same way PackageDefHandler and ImportHandler are separate.
|
False negative... when an annotation is on its own line, the line with the module keyword is never checked |
|
Github, generate report for Indentation/all-examples-in-one |
|
Report generation failed. Please check the logs for more details. |
7cbbbb2 to
9cf9efa
Compare
|
Github, generate report for Indentation/all-examples-in-one |
|
Report generation failed. Please check the logs for more details. |
3d84f45 to
13e6c80
Compare
|
@sahitya0xsingh Always run |
13e6c80 to
6db8d30
Compare
|
Please generate the regression report to test your changes create the config that test your changes and than generate the report |
a63fd29 to
266fc19
Compare
|
GitHub, generate report for configs in PR description |
|
Report generation failed. Please check the logs for more details. |
266fc19 to
1711174
Compare
|
Failed to parse comment command. |
1711174 to
352796c
Compare
1aec557 to
e5f77a0
Compare
e5f77a0 to
982753b
Compare
|
GitHub, generate report for configs in PR description |
|
Report generation failed. Please check the logs for more details. |
|
GitHub, generate report for configs in PR description |
|
Report generation failed. Please check the logs for more details. |
|
GitHub, generate report for configs in PR description |
Fixes #21160
Reason for Change:
The
Indentationcheck currently does not provide support for enforcing indentation within Java 9moduledeclarations (module-info.java). Directives inside a module body (requires,exports,opens, etc.) were completely skipped becauseHandlerFactoryhad no registered handlers forMODULE_DEFandDIRECTIVE_BLOCK.Implementation Details:
ModuleDirectiveHandlerextendingBlockParentHandlerto correctly enforce standard block indentation for module body directives.HandlerFactoryforTokenTypes.MODULE_DEFandTokenTypes.DIRECTIVE_BLOCK.ClassDefHandlerto slightly reduce complexity and ensure it cleanly processes class and record structures without interfering with module definitions.IndentationCheckTest.javaand a correspondingInputIndentationModuleInfo.javaresource file containing various correct and incorrect module indentation scenarios.checkstyle-resources-suppressions.xmlto suppress thePackageDeclarationCheckfor the newInputIndentationModuleInfo.javatest file, as module-info files intentionally do not contain package declarations.All existing and new tests pass, and full branch coverage is maintained.
Regression Test Config
Diff Regression config: https://gist.githubusercontent.com/sahitya0xsingh/09550ca20fed731f3038fbc66a61b63c/raw/regression-config.xml