Skip to content

Commit 8e6be0f

Browse files
committed
Refine tag regex to deal with {@code ...} text
Update `AT_TAG_PATTERN` regex in `SpringJavadocCheck` so that text with `{@code ...}` escapes aren't considered. Fixes gh-291
1 parent a40fa14 commit 8e6be0f

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringJavadocCheck.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2020 the original author or authors.
2+
* Copyright 2017-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -56,7 +56,7 @@ public class SpringJavadocCheck extends AbstractSpringCheck {
5656

5757
private static final Pattern SINCE_TAG_PATTERN = Pattern.compile("@since\\s+(.*)");
5858

59-
private static final Pattern AT_TAG_PATTERN = Pattern.compile("@\\w+\\s+.*");
59+
private static final Pattern AT_TAG_PATTERN = Pattern.compile("[^{]@\\w+\\s+.*");
6060

6161
private static final Pattern NON_JAVADOC_COMMENT = Pattern.compile("\\(non-Javadoc\\)", Pattern.CASE_INSENSITIVE);
6262

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
+0 errors
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2017-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* Javadoc with white space.
19+
* @param <T> this is a valid param
20+
* @author Sushant Kumar Singh
21+
*/
22+
public class JavadocMethodEmptyLineBeforeTagWithStarAtEnd<T> {
23+
24+
/**
25+
* First paragraph.
26+
*
27+
* <p>Second paragraph contains an asterisk in a code element: {@code *}.
28+
* @since 1.0
29+
*/
30+
public void test() {
31+
}
32+
33+
}

0 commit comments

Comments
 (0)