New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OuterTypeFileName throws NPE on record definition in method #8598
Comments
Some ideas to solve this issue:
|
AST before proposed grammar change:
AST after proposed grammar change:
Note that this change only affects record definitions within method definitions. Example of record definition within a class: checkstyle/src/test/resources/com/puppycrawl/tools/checkstyle/grammar/java14/InputJava14Records.txt Lines 1127 to 1142 in 86e2754
This is the record definition usage that would be affected: checkstyle/src/test/resources/com/puppycrawl/tools/checkstyle/grammar/java14/InputJava14Records.txt Lines 1244 to 1257 in 86e2754
|
…tementCountCheck
@nmancus1 , please update issue to mention that we probably do empty modifiers for other types, so update of AST is good to keep structure the same among types. |
…eck for updated UT(checkstyle#8598)
CLI output from current master:
CLI output from proposed changes:
In order to be more consistent with other types, such as classes, we need to employ the proposed changes to our java grammar. Many of our checks depend on a |
fix is merged. |
…eck for updated UT(checkstyle#8598)
Check documentation: https://checkstyle.sourceforge.io/config_misc.html#OuterTypeFilename
Relevant grammar from
java.g
:checkstyle/src/main/resources/com/puppycrawl/tools/checkstyle/grammar/java.g
Lines 1121 to 1122 in 86e2754
Since the modifiers AST is null when a record definition is inside of a method, a NPE is thrown here:
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/OuterTypeFilenameCheck.java
Line 142 in 86e2754
The text was updated successfully, but these errors were encountered: