Skip to content

Commit

Permalink
Issue checkstyle#14881: remove null from visitJavaDocToken
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitsatr authored and romani committed Dec 10, 2024
1 parent 6d17cb2 commit 0e5e0a9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4328,28 +4328,6 @@
<lineContent>private Scope excludeScope;</lineContent>
</checkerFrameworkError>

<checkerFrameworkError unstable="false">
<fileName>src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck.java</fileName>
<specifier>argument</specifier>
<message>incompatible argument for parameter javadocInlineTag of SummaryJavadocCheck.isInlineReturnTag.</message>
<lineContent>else if (inlineTag.isPresent() &amp;&amp; isInlineReturnTag(inlineTagNode)) {</lineContent>
<details>
found : @Initialized @Nullable DetailNode
required: @Initialized @NonNull DetailNode
</details>
</checkerFrameworkError>

<checkerFrameworkError unstable="false">
<fileName>src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck.java</fileName>
<specifier>argument</specifier>
<message>incompatible argument for parameter javadocInlineTag of SummaryJavadocCheck.isSummaryTag.</message>
<lineContent>&amp;&amp; isSummaryTag(inlineTagNode)</lineContent>
<details>
found : @Initialized @Nullable DetailNode
required: @Initialized @NonNull DetailNode
</details>
</checkerFrameworkError>

<checkerFrameworkError unstable="false">
<fileName>src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck.java</fileName>
<specifier>return</specifier>
Expand Down
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,10 @@
<configuration>
<javaVersion>${java.version}</javaVersion>
<includeTestClasses>false</includeTestClasses>
<exclusionPatterns>
<!-- until https://github.com/gaul/modernizer-maven-plugin/issues/300 -->
<exclusionPattern>java/util/Optional.get:.*</exclusionPattern>
</exclusionPatterns>
</configuration>
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,20 @@ public int[] getRequiredJavadocTokens() {

@Override
public void visitJavadocToken(DetailNode ast) {
final Optional<DetailNode> inlineTag = getInlineTagNode(ast);
final DetailNode inlineTagNode = inlineTag.orElse(null);
if (inlineTag.isPresent()
&& isSummaryTag(inlineTagNode)
&& isDefinedFirst(inlineTagNode)) {
validateSummaryTag(inlineTagNode);
}
else if (inlineTag.isPresent() && isInlineReturnTag(inlineTagNode)) {
validateInlineReturnTag(inlineTagNode);
final Optional<DetailNode> inlineTagNode = getInlineTagNode(ast);
boolean shouldValidateUntaggedSummary = true;
if (inlineTagNode.isPresent()) {
final DetailNode node = inlineTagNode.get();
if (isSummaryTag(node) && isDefinedFirst(node)) {
shouldValidateUntaggedSummary = false;
validateSummaryTag(node);
}
else if (isInlineReturnTag(node)) {
shouldValidateUntaggedSummary = false;
validateInlineReturnTag(node);
}
}
else if (!startsWithInheritDoc(ast)) {
if (shouldValidateUntaggedSummary && !startsWithInheritDoc(ast)) {
validateUntaggedSummary(ast);
}
}
Expand Down

0 comments on commit 0e5e0a9

Please sign in to comment.