-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Description
I have read check documentation: https://checkstyle.org/checks/coding/textblockgooglestyleformatting.html
I have downloaded the latest checkstyle from: https://checkstyle.org/cmdline.html#Download_and_Run
I have executed the cli and showed it below, as cli describes the problem better than 1,000 words
$ javac Example.java
$ cat config.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<module name="TextBlockGoogleStyleFormatting"/>
</module>
</module>
$ cat Example.java
@SuppressWarnings(
"""
Text block in annotation.
""")
public class Example {
}
$ RUN_LOCALE="-Duser.language=en -Duser.country=US"
$ java $RUN_LOCALE -jar checkstyle-12.3.0-all.jar -c config.xml Example.java
Starting audit...
com.puppycrawl.tools.checkstyle.api.CheckstyleException: Exception was thrown while processing Example.java
at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:313)
at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:227)
at com.puppycrawl.tools.checkstyle.Main.runCheckstyle(Main.java:429)
at com.puppycrawl.tools.checkstyle.Main.runCli(Main.java:347)
at com.puppycrawl.tools.checkstyle.Main.execute(Main.java:206)
at com.puppycrawl.tools.checkstyle.Main.main(Main.java:130)
Caused by: java.lang.NullPointerException: Cannot invoke "com.puppycrawl.tools.checkstyle.api.DetailAST.getType()" because "parent" is null
at com.puppycrawl.tools.checkstyle.checks.coding.TextBlockGoogleStyleFormattingCheck.openingQuotesAreAloneOnTheLine(TextBlockGoogleStyleFormattingCheck.java:136)
at com.puppycrawl.tools.checkstyle.checks.coding.TextBlockGoogleStyleFormattingCheck.visitToken(TextBlockGoogleStyleFormattingCheck.java:87)
at com.puppycrawl.tools.checkstyle.TreeWalker.notifyVisit(TreeWalker.java:390)
at com.puppycrawl.tools.checkstyle.TreeWalker.processIter(TreeWalker.java:463)
at com.puppycrawl.tools.checkstyle.TreeWalker.walk(TreeWalker.java:328)
at com.puppycrawl.tools.checkstyle.TreeWalker.processFiltered(TreeWalker.java:208)
at com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck.process(AbstractFileSetCheck.java:101)
at com.puppycrawl.tools.checkstyle.Checker.processFile(Checker.java:341)
at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:300)
... 5 more
Checkstyle ends with 1 errors.
I expect checkstyle to not throw report any issues in the code and not fail with a NullPointerException.
The above example is a minimal example using @SuppressWarnings since that is an annotation that is available without libraries. The problem was encountered using another annotation where using a text block was more meaningful.