Skip to content

Commit f5e491c

Browse files
authored
Merge pull request github#3448 from yo-h/java-qldoc-add
Java: improve QLDoc completeness
2 parents 3c233c7 + a884538 commit f5e491c

File tree

20 files changed

+731
-22
lines changed

20 files changed

+731
-22
lines changed

java/ql/src/Advisory/Documentation/JavadocCommon.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** Provides classes and predicates related to Javadoc conventions. */
2+
13
import java
24

35
/** Holds if the given `Javadoc` contains a minimum of a few characters of text. */
@@ -29,6 +31,7 @@ class DocuRefType extends RefType {
2931
this.isPublic()
3032
}
3133

34+
/** Holds if the Javadoc for this type contains a minimum of a few characters of text. */
3235
predicate hasAcceptableDocText() { acceptableDocText(this.getDoc().getJavadoc()) }
3336
}
3437

@@ -46,8 +49,10 @@ class DocuCallable extends Callable {
4649
not this.getLocation() = this.getDeclaringType().getLocation()
4750
}
4851

52+
/** Holds if the Javadoc for this callable contains a minimum of a few characters of text. */
4953
predicate hasAcceptableDocText() { acceptableDocText(this.getDoc().getJavadoc()) }
5054

55+
/** Gets a string to identify whether this callable is a "method" or a "constructor". */
5156
string toMethodOrConstructorString() {
5257
this instanceof Method and result = "method"
5358
or

java/ql/src/Advisory/Naming/NamingConventionsCommon.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
/** Provides classes and predicates related to Java naming conventions. */
2+
13
import java
24

5+
/** A field that is both `static` and `final`. */
36
class ConstantField extends Field {
47
ConstantField() {
58
this.isStatic() and

java/ql/src/Architecture/Dependencies/UnusedMavenDependencies.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** Provides classes and predicates for working with Maven dependencies. */
2+
13
import java
24
import semmle.code.xml.MavenPom
35

java/ql/src/Compatibility/JDK9/JdkInternals.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Provides predicates for identifying unsupported JDK-internal APIs.
3+
*/
4+
15
/**
26
* Provides a QL encoding of the list of unsupported JDK-internal APIs at:
37
*

java/ql/src/Compatibility/JDK9/JdkInternalsReplacement.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Provides predicates for identifying suggested replacements for unsupported JDK-internal APIs.
3+
*/
4+
15
/**
26
* Provides a QL encoding of the suggested replacements for unsupported JDK-internal APIs listed at:
37
*

java/ql/src/default.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
/** DEPRECATED: use `java.qll` instead. */
2+
13
import java

java/ql/src/external/Clover.qll

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** Provides classes and predicates for working with Clover reports. */
2+
13
import java
24

35
/**
@@ -18,6 +20,7 @@ class CloverCoverage extends XMLElement {
1820
this.getName() = "coverage"
1921
}
2022

23+
/** Gets a project for this `coverage` element. */
2124
CloverProject getAProject() { result = this.getAChild() }
2225
}
2326

@@ -27,6 +30,7 @@ class CloverCoverage extends XMLElement {
2730
* all subclasses of this class, to share code.
2831
*/
2932
abstract class CloverMetricsContainer extends XMLElement {
33+
/** Gets the Clover `metrics` child element for this element. */
3034
CloverMetrics getMetrics() { result = this.getAChild() }
3135
}
3236

@@ -44,42 +48,61 @@ class CloverMetrics extends XMLElement {
4448

4549
private float ratio(string name) { result = attr("covered" + name) / attr(name).(float) }
4650

51+
/** Gets the value of the `conditionals` attribute. */
4752
int getNumConditionals() { result = attr("conditionals") }
4853

54+
/** Gets the value of the `coveredconditionals` attribute. */
4955
int getNumCoveredConditionals() { result = attr("coveredconditionals") }
5056

57+
/** Gets the value of the `statements` attribute. */
5158
int getNumStatements() { result = attr("statements") }
5259

60+
/** Gets the value of the `coveredstatements` attribute. */
5361
int getNumCoveredStatements() { result = attr("coveredstatements") }
5462

63+
/** Gets the value of the `elements` attribute. */
5564
int getNumElements() { result = attr("elements") }
5665

66+
/** Gets the value of the `coveredelements` attribute. */
5767
int getNumCoveredElements() { result = attr("coveredelements") }
5868

69+
/** Gets the value of the `methods` attribute. */
5970
int getNumMethods() { result = attr("methods") }
6071

72+
/** Gets the value of the `coveredmethods` attribute. */
6173
int getNumCoveredMethods() { result = attr("coveredmethods") }
6274

75+
/** Gets the value of the `loc` attribute. */
6376
int getNumLoC() { result = attr("loc") }
6477

78+
/** Gets the value of the `ncloc` attribute. */
6579
int getNumNonCommentedLoC() { result = attr("ncloc") }
6680

81+
/** Gets the value of the `packages` attribute. */
6782
int getNumPackages() { result = attr("packages") }
6883

84+
/** Gets the value of the `files` attribute. */
6985
int getNumFiles() { result = attr("files") }
7086

87+
/** Gets the value of the `classes` attribute. */
7188
int getNumClasses() { result = attr("classes") }
7289

90+
/** Gets the value of the `complexity` attribute. */
7391
int getCloverComplexity() { result = attr("complexity") }
7492

93+
/** Gets the ratio of the `coveredconditionals` attribute over the `conditionals` attribute. */
7594
float getConditionalCoverage() { result = ratio("conditionals") }
7695

96+
/** Gets the ratio of the `coveredstatements` attribute over the `statements` attribute. */
7797
float getStatementCoverage() { result = ratio("statements") }
7898

99+
/** Gets the ratio of the `coveredelements` attribute over the `elements` attribute. */
79100
float getElementCoverage() { result = ratio("elements") }
80101

102+
/** Gets the ratio of the `coveredmethods` attribute over the `methods` attribute. */
81103
float getMethodCoverage() { result = ratio("methods") }
82104

105+
/** Gets the ratio of the `ncloc` attribute over the `loc` attribute. */
83106
float getNonCommentedLoCRatio() { result = attr("ncloc") / attr("loc") }
84107
}
85108

@@ -100,6 +123,7 @@ class CloverPackage extends CloverMetricsContainer {
100123
this.getName() = "package"
101124
}
102125

126+
/** Gets the Java package for this Clover package. */
103127
Package getRealPackage() { result.hasName(getAttribute("name").getValue()) }
104128
}
105129

@@ -122,8 +146,10 @@ class CloverClass extends CloverMetricsContainer {
122146
this.getName() = "class"
123147
}
124148

149+
/** Gets the Clover package for this Clover class. */
125150
CloverPackage getPackage() { result = getParent().(CloverFile).getParent() }
126151

152+
/** Gets the Java type for this Clover class. */
127153
RefType getRealClass() {
128154
result
129155
.hasQualifiedName(getPackage().getAttribute("name").getValue(),
Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,50 @@
1+
/**
2+
* Provides classes and predicates for working with annotations in the `javax` package.
3+
*/
4+
15
import java
26

37
/*
4-
* javax.annotation annotations
8+
* Annotations in the package `javax.annotation`.
59
*/
610

11+
/**
12+
* A `@javax.annotation.Generated` annotation.
13+
*/
714
class GeneratedAnnotation extends Annotation {
815
GeneratedAnnotation() { this.getType().hasQualifiedName("javax.annotation", "Generated") }
916
}
1017

18+
/**
19+
* A `@javax.annotation.PostConstruct` annotation.
20+
*/
1121
class PostConstructAnnotation extends Annotation {
1222
PostConstructAnnotation() { this.getType().hasQualifiedName("javax.annotation", "PostConstruct") }
1323
}
1424

25+
/**
26+
* A `@javax.annotation.PreDestroy` annotation.
27+
*/
1528
class PreDestroyAnnotation extends Annotation {
1629
PreDestroyAnnotation() { this.getType().hasQualifiedName("javax.annotation", "PreDestroy") }
1730
}
1831

32+
/**
33+
* A `@javax.annotation.Resource` annotation.
34+
*/
1935
class ResourceAnnotation extends Annotation {
2036
ResourceAnnotation() { this.getType().hasQualifiedName("javax.annotation", "Resource") }
2137
}
2238

39+
/**
40+
* A `@javax.annotation.Resources` annotation.
41+
*/
2342
class ResourcesAnnotation extends Annotation {
2443
ResourcesAnnotation() { this.getType().hasQualifiedName("javax.annotation", "Resources") }
2544
}
2645

2746
/**
28-
* A javax.annotation.ManagedBean annotation.
47+
* A `@javax.annotation.ManagedBean` annotation.
2948
*/
3049
class JavaxManagedBeanAnnotation extends Annotation {
3150
JavaxManagedBeanAnnotation() {
@@ -34,71 +53,104 @@ class JavaxManagedBeanAnnotation extends Annotation {
3453
}
3554

3655
/*
37-
* javax.annotation.security annotations
56+
* Annotations in the package `javax.annotation.security`.
3857
*/
3958

59+
/**
60+
* A `@javax.annotation.security.DeclareRoles` annotation.
61+
*/
4062
class DeclareRolesAnnotation extends Annotation {
4163
DeclareRolesAnnotation() {
4264
this.getType().hasQualifiedName("javax.annotation.security", "DeclareRoles")
4365
}
4466
}
4567

68+
/**
69+
* A `@javax.annotation.security.DenyAll` annotation.
70+
*/
4671
class DenyAllAnnotation extends Annotation {
4772
DenyAllAnnotation() { this.getType().hasQualifiedName("javax.annotation.security", "DenyAll") }
4873
}
4974

75+
/**
76+
* A `@javax.annotation.security.PermitAll` annotation.
77+
*/
5078
class PermitAllAnnotation extends Annotation {
5179
PermitAllAnnotation() {
5280
this.getType().hasQualifiedName("javax.annotation.security", "PermitAll")
5381
}
5482
}
5583

84+
/**
85+
* A `@javax.annotation.security.RolesAllowed` annotation.
86+
*/
5687
class RolesAllowedAnnotation extends Annotation {
5788
RolesAllowedAnnotation() {
5889
this.getType().hasQualifiedName("javax.annotation.security", "RolesAllowed")
5990
}
6091
}
6192

93+
/**
94+
* A `@javax.annotation.security.RunAs` annotation.
95+
*/
6296
class RunAsAnnotation extends Annotation {
6397
RunAsAnnotation() { this.getType().hasQualifiedName("javax.annotation.security", "RunAs") }
6498
}
6599

66100
/*
67-
* javax.interceptor annotations
101+
* Annotations in the package `javax.interceptor`.
68102
*/
69103

104+
/**
105+
* A `@javax.interceptor.AroundInvoke` annotation.
106+
*/
70107
class AroundInvokeAnnotation extends Annotation {
71108
AroundInvokeAnnotation() { this.getType().hasQualifiedName("javax.interceptor", "AroundInvoke") }
72109
}
73110

111+
/**
112+
* A `@javax.interceptor.ExcludeClassInterceptors` annotation.
113+
*/
74114
class ExcludeClassInterceptorsAnnotation extends Annotation {
75115
ExcludeClassInterceptorsAnnotation() {
76116
this.getType().hasQualifiedName("javax.interceptor", "ExcludeClassInterceptors")
77117
}
78118
}
79119

120+
/**
121+
* A `@javax.interceptor.ExcludeDefaultInterceptors` annotation.
122+
*/
80123
class ExcludeDefaultInterceptorsAnnotation extends Annotation {
81124
ExcludeDefaultInterceptorsAnnotation() {
82125
this.getType().hasQualifiedName("javax.interceptor", "ExcludeDefaultInterceptors")
83126
}
84127
}
85128

129+
/**
130+
* A `@javax.interceptor.Interceptors` annotation.
131+
*/
86132
class InterceptorsAnnotation extends Annotation {
87133
InterceptorsAnnotation() { this.getType().hasQualifiedName("javax.interceptor", "Interceptors") }
88134
}
89135

90136
/*
91-
* javax.jws annotations
137+
* Annotations in the package `javax.jws`.
92138
*/
93139

140+
/**
141+
* A `@javax.jws.WebService` annotation.
142+
*/
94143
class WebServiceAnnotation extends Annotation {
95144
WebServiceAnnotation() { this.getType().hasQualifiedName("javax.jws", "WebService") }
96145
}
97146

98147
/*
99-
* javax.xml.ws annotations
148+
* Annotations in the package `javax.xml.ws`.
100149
*/
101150

151+
/**
152+
* A `@javax.xml.ws.WebServiceRef` annotation.
153+
*/
102154
class WebServiceRefAnnotation extends Annotation {
103155
WebServiceRefAnnotation() { this.getType().hasQualifiedName("javax.xml.ws", "WebServiceRef") }
104156
}

java/ql/src/semmle/code/java/frameworks/gwt/GWT.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** Provides classes and predicates for working with the GWT framework. */
2+
13
import java
24
import GwtXml
35
import GwtUiBinder

java/ql/src/semmle/code/java/frameworks/gwt/GwtUiBinder.qll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,44 @@
88
import java
99
import GwtUiBinderXml
1010

11+
/**
12+
* An annotation in the package `com.google.gwt.uibinder.client`.
13+
*/
1114
class GwtUiBinderClientAnnotation extends Annotation {
1215
GwtUiBinderClientAnnotation() { getType().getPackage().hasName("com.google.gwt.uibinder.client") }
1316
}
1417

18+
/**
19+
* A `@com.google.gwt.uibinder.client.UiHandler` annotation.
20+
*/
1521
class GwtUiHandlerAnnotation extends GwtUiBinderClientAnnotation {
1622
GwtUiHandlerAnnotation() { getType().hasName("UiHandler") }
1723
}
1824

25+
/**
26+
* A `@com.google.gwt.uibinder.client.UiField` annotation.
27+
*/
1928
class GwtUiFieldAnnotation extends GwtUiBinderClientAnnotation {
2029
GwtUiFieldAnnotation() { getType().hasName("UiField") }
2130
}
2231

32+
/**
33+
* A `@com.google.gwt.uibinder.client.UiTemplate` annotation.
34+
*/
2335
class GwtUiTemplateAnnotation extends GwtUiBinderClientAnnotation {
2436
GwtUiTemplateAnnotation() { getType().hasName("UiTemplate") }
2537
}
2638

39+
/**
40+
* A `@com.google.gwt.uibinder.client.UiFactory` annotation.
41+
*/
2742
class GwtUiFactoryAnnotation extends GwtUiBinderClientAnnotation {
2843
GwtUiFactoryAnnotation() { getType().hasName("UiFactory") }
2944
}
3045

46+
/**
47+
* A `@com.google.gwt.uibinder.client.UiConstructor` annotation.
48+
*/
3149
class GwtUiConstructorAnnotation extends GwtUiBinderClientAnnotation {
3250
GwtUiConstructorAnnotation() { getType().hasName("UiConstructor") }
3351
}

0 commit comments

Comments
 (0)