Skip to content

Commit

Permalink
Refine tag regex to deal with {@code ...} text
Browse files Browse the repository at this point in the history
Update `AT_TAG_PATTERN` regex in `SpringJavadocCheck` so that
text with `{@code ...}` escapes aren't considered.

Fixes gh-291
  • Loading branch information
philwebb committed Sep 28, 2021
1 parent a40fa14 commit 8e6be0f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 the original author or authors.
* Copyright 2017-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -56,7 +56,7 @@ public class SpringJavadocCheck extends AbstractSpringCheck {

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

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
+0 errors
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2017-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Javadoc with white space.
* @param <T> this is a valid param
* @author Sushant Kumar Singh
*/
public class JavadocMethodEmptyLineBeforeTagWithStarAtEnd<T> {

/**
* First paragraph.
*
* <p>Second paragraph contains an asterisk in a code element: {@code *}.
* @since 1.0
*/
public void test() {
}

}

0 comments on commit 8e6be0f

Please sign in to comment.