File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
codeql-custom-queries-java/queries/javadoc Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * Finds empty Javadoc inline tags for tags which normally expect a value, e.g. `{@code}`.
3
+ * In that case the empty inline tag has no effect (except for `{@value}` on fields), so most
4
+ * likely the inline tag in the documentation comment is empty by accident.
5
+ *
6
+ * @kind problem
7
+ */
8
+
9
+ import java
10
+
11
+ from JavadocText javadocText , string tagName , string inlineTag
12
+ where
13
+ // Note: For some tags such as {@index} javadoc command displays an error
14
+ (
15
+ tagName = [
16
+ "code" ,
17
+ "index" ,
18
+ "link" ,
19
+ "linkplain" ,
20
+ "literal" ,
21
+ "summary" ,
22
+ "systemProperty"
23
+ ]
24
+ or
25
+ // {@value} is allowed for fields
26
+ tagName = "value"
27
+ and not exists ( Javadoc javadoc |
28
+ javadoc = javadocText .getJavadoc ( )
29
+ and javadoc .getCommentedElement ( ) instanceof Field
30
+ )
31
+ )
32
+ and inlineTag = javadocText .getText ( ) .regexpFind ( "\\{@" + tagName + "\\s*\\}" , _, _)
33
+ select javadocText , "Contains empty inline tag: " + inlineTag
You can’t perform that action at this time.
0 commit comments