Skip to content

Commit 807d778

Browse files
committed
Add inline-return-tag-redundant-punctuation.ql
1 parent ee732e9 commit 807d778

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Finds redundant punctuation for Javadoc inline `{@return ...}` tags.
3+
* The tag automatically creates documentation in the form "Returns <text>.",
4+
* so there should not be any punctuation behind it since that would lead to
5+
* duplicate or incorrect punctuation.
6+
*
7+
* @kind problem
8+
* @id TODO
9+
*/
10+
11+
import java
12+
import lib.JavadocLib
13+
14+
from Javadoc javadoc, string text
15+
where
16+
text = getCompleteJavadocText(javadoc) and
17+
exists(
18+
text.regexpFind([
19+
// TODO: Has false positives for embedded inline tag, e.g. `{@return ... {@code ...} ...}
20+
// use own `JavadocLib.qll` for parsing inline tags?
21+
// Trailing punctuation in front of '}'
22+
"\\{@return\\s.+[.,:;-]\\s*\\}",
23+
// Trailing punctuaction or lowercase char behind '}'
24+
"\\{@return\\s.+\\}\\s*([.,:;-]|[a-z])",
25+
], _, _)
26+
)
27+
select javadoc, "Redundant punctuation or incorrectly capitalized text for `{@return ...}`"

0 commit comments

Comments
 (0)