File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
codeql-custom-queries-java/queries/javadoc Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 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 ...}`"
You can’t perform that action at this time.
0 commit comments