Skip to content

Commit a8be7f2

Browse files
authored
Merge pull request #312 from aschackmull/java/autoformat-libs
Approved by yh-semmle
2 parents 9ec52a4 + 22c986a commit a8be7f2

File tree

229 files changed

+22727
-21545
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

229 files changed

+22727
-21545
lines changed

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll

Lines changed: 1496 additions & 1369 deletions
Large diffs are not rendered by default.

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll

Lines changed: 1496 additions & 1369 deletions
Large diffs are not rendered by default.

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll

Lines changed: 1496 additions & 1369 deletions
Large diffs are not rendered by default.

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll

Lines changed: 1496 additions & 1369 deletions
Large diffs are not rendered by default.

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import DataFlowUtil
32
private import DataFlowPrivate
43
private import DataFlowDispatch
@@ -55,9 +54,7 @@ private module ImplCommon {
5554
*/
5655
cached
5756
predicate parameterValueFlowsThrough(ParameterNode p) {
58-
exists(ReturnNode ret |
59-
parameterValueFlow(p, ret)
60-
)
57+
exists(ReturnNode ret | parameterValueFlow(p, ret))
6158
}
6259

6360
/**
@@ -112,8 +109,10 @@ private module ImplCommon {
112109
storeViaSideEffect(node1, f, node2) or
113110
storeReturn(node1, f, node2)
114111
}
112+
115113
private predicate storeViaSideEffect(Node node1, Content f, PostUpdateNode node2) {
116-
storeStep(node1, f, node2) and readStep(_, f, _) or
114+
storeStep(node1, f, node2) and readStep(_, f, _)
115+
or
117116
exists(Call call, int i1, int i2 |
118117
setterCall(call, i1, i2, f) and
119118
node1.(ArgumentNode).argumentOf(call, i1) and
@@ -122,6 +121,7 @@ private module ImplCommon {
122121
compatibleTypes(node2.getTypeBound(), f.getDeclaringType())
123122
)
124123
}
124+
125125
pragma[nomagic]
126126
private predicate setterInParam(ParameterNode p1, Content f, ParameterNode p2) {
127127
exists(Node n1, PostUpdateNode n2 |
@@ -131,6 +131,7 @@ private module ImplCommon {
131131
p1 != p2
132132
)
133133
}
134+
134135
pragma[nomagic]
135136
private predicate setterCall(Call call, int i1, int i2, Content f) {
136137
exists(Callable callable, ParameterNode p1, ParameterNode p2 |
@@ -140,6 +141,7 @@ private module ImplCommon {
140141
p2.isParameterOf(callable, i2)
141142
)
142143
}
144+
143145
private predicate storeReturn(Node node1, Content f, Node node2) {
144146
exists(ParameterNode p, ArgumentNode arg |
145147
arg = node1 and
@@ -150,6 +152,7 @@ private module ImplCommon {
150152
compatibleTypes(node2.getTypeBound(), f.getDeclaringType())
151153
)
152154
}
155+
153156
private predicate setterReturn(ParameterNode p, Content f) {
154157
exists(Node n1, Node n2, ReturnNode ret |
155158
parameterValueFlow(p, n1) and
@@ -164,7 +167,8 @@ private module ImplCommon {
164167
*/
165168
cached
166169
predicate read(Node node1, Content f, Node node2) {
167-
readStep(node1, f, node2) and storeStep(_, f, _) or
170+
readStep(node1, f, node2) and storeStep(_, f, _)
171+
or
168172
exists(ParameterNode p, ArgumentNode arg |
169173
arg = node1 and
170174
viableParamArg(p, arg) and
@@ -174,6 +178,7 @@ private module ImplCommon {
174178
compatibleTypes(node2.getTypeBound(), f.getType())
175179
)
176180
}
181+
177182
private predicate getter(ParameterNode p, Content f) {
178183
exists(Node n1, Node n2, ReturnNode ret |
179184
parameterValueFlow(p, n1) and
@@ -196,9 +201,7 @@ private module ImplCommon {
196201
* expression that reaches a `this` parameter.
197202
*/
198203
private predicate callHasInstanceArgument(Call call) {
199-
exists(ArgumentNode arg |
200-
arg.argumentOf(call, -1)
201-
)
204+
exists(ArgumentNode arg | arg.argumentOf(call, -1))
202205
}
203206

204207
cached
@@ -207,9 +210,11 @@ private module ImplCommon {
207210
TSpecificCall(Call call, int i, boolean emptyAp) {
208211
reducedViableImplInCallContext(_, _, call) and
209212
(emptyAp = true or emptyAp = false) and
210-
(exists(call.getArgument(i))
211-
or
212-
i = -1 and callHasInstanceArgument(call))
213+
(
214+
exists(call.getArgument(i))
215+
or
216+
i = -1 and callHasInstanceArgument(call)
217+
)
213218
} or
214219
TSomeCall(ParameterNode p, boolean emptyAp) { emptyAp = true or emptyAp = false } or
215220
TReturn(Method m, MethodAccess ma) { reducedViableImplInReturn(m, ma) }
@@ -232,19 +237,22 @@ import ImplCommon
232237
* this dispatch target of `ma` implies a reduced set of dispatch origins
233238
* to which data may flow if it should reach a `return` statement.
234239
*/
235-
abstract class CallContext extends TCallContext {
236-
abstract string toString();
237-
}
240+
abstract class CallContext extends TCallContext { abstract string toString(); }
241+
238242
class CallContextAny extends CallContext, TAnyCallContext {
239243
override string toString() { result = "CcAny" }
240244
}
245+
241246
abstract class CallContextCall extends CallContext { }
247+
242248
class CallContextSpecificCall extends CallContextCall, TSpecificCall {
243249
override string toString() { result = "CcCall" }
244250
}
251+
245252
class CallContextSomeCall extends CallContextCall, TSomeCall {
246253
override string toString() { result = "CcSomeCall" }
247254
}
255+
248256
class CallContextReturn extends CallContext, TReturn {
249257
override string toString() { result = "CcReturn" }
250258
}
@@ -263,12 +271,14 @@ predicate resolveReturn(CallContext cc, Callable callable, Call call) {
263271
bindingset[call, cc]
264272
Callable resolveCall(Call call, CallContext cc) {
265273
exists(Call ctx | cc = TSpecificCall(ctx, _, _) |
266-
if reducedViableImplInCallContext(call, _, ctx) then
267-
result = prunedViableImplInCallContext(call, ctx)
268-
else
269-
result = viableCallable(call)
270-
) or
271-
result = viableCallable(call) and cc instanceof CallContextSomeCall or
272-
result = viableCallable(call) and cc instanceof CallContextAny or
274+
if reducedViableImplInCallContext(call, _, ctx)
275+
then result = prunedViableImplInCallContext(call, ctx)
276+
else result = viableCallable(call)
277+
)
278+
or
279+
result = viableCallable(call) and cc instanceof CallContextSomeCall
280+
or
281+
result = viableCallable(call) and cc instanceof CallContextAny
282+
or
273283
result = viableCallable(call) and cc instanceof CallContextReturn
274284
}

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
import java
22

33
/** Holds if the given `Javadoc` contains a minimum of a few characters of text. */
4-
private
5-
predicate acceptableDocText(Javadoc j) {
4+
private predicate acceptableDocText(Javadoc j) {
65
// Require minimum combined length of all non-tag elements.
76
sum(JavadocElement e, int toSum |
87
e = j.getAChild() and
98
not e = j.getATag(_) and
109
toSum = e.toString().length()
11-
|
10+
|
1211
toSum
1312
) >= 5
1413
}
1514

1615
/** Holds if the given `JavadocTag` contains a minimum of a few characters of text. */
17-
private
18-
predicate acceptableTag(JavadocTag t) {
16+
private predicate acceptableTag(JavadocTag t) {
1917
sum(JavadocElement e, int toSum |
2018
e = t.getAChild() and
2119
toSum = e.toString().length()
22-
|
20+
|
2321
toSum
2422
) >= 5
2523
}
@@ -31,9 +29,7 @@ class DocuRefType extends RefType {
3129
this.isPublic()
3230
}
3331

34-
predicate hasAcceptableDocText() {
35-
acceptableDocText(this.getDoc().getJavadoc())
36-
}
32+
predicate hasAcceptableDocText() { acceptableDocText(this.getDoc().getJavadoc()) }
3733
}
3834

3935
/** A public (non-getter, non-setter) `Callable` that does not override another method. */
@@ -50,12 +46,11 @@ class DocuCallable extends Callable {
5046
not this.getLocation() = this.getDeclaringType().getLocation()
5147
}
5248

53-
predicate hasAcceptableDocText() {
54-
acceptableDocText(this.getDoc().getJavadoc())
55-
}
49+
predicate hasAcceptableDocText() { acceptableDocText(this.getDoc().getJavadoc()) }
5650

5751
string toMethodOrConstructorString() {
58-
(this instanceof Method and result = "method") or
52+
(this instanceof Method and result = "method")
53+
or
5954
(this instanceof Constructor and result = "constructor")
6055
}
6156
}

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ import semmle.code.xml.MavenPom
66
* within the given container (folder, jar file etc.).
77
*/
88
predicate pomDependsOnContainer(Pom f, Container g) {
9-
exists(RefType source, RefType target |
10-
source.getFile().getParentContainer*() = f.getFile().getParentContainer() and
11-
target.getFile().getParentContainer*() = g and
12-
depends(source, target)
13-
)
9+
exists(RefType source, RefType target |
10+
source.getFile().getParentContainer*() = f.getFile().getParentContainer() and
11+
target.getFile().getParentContainer*() = g and
12+
depends(source, target)
13+
)
1414
}
1515

1616
/**
1717
* Holds if the source code in the project represented by the sourcePom depends on any code
1818
* within the project represented by the targetPom.
1919
*/
2020
predicate pomDependsOnPom(Pom sourcePom, Pom targetPom) {
21-
exists(RefType source, RefType target |
22-
source.getFile().getParentContainer*() = sourcePom.getFile().getParentContainer() and
23-
target.getFile().getParentContainer*() = targetPom.getFile().getParentContainer() and
24-
depends(source, target)
25-
)
21+
exists(RefType source, RefType target |
22+
source.getFile().getParentContainer*() = sourcePom.getFile().getParentContainer() and
23+
target.getFile().getParentContainer*() = targetPom.getFile().getParentContainer() and
24+
depends(source, target)
25+
)
2626
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*
44
* http://hg.openjdk.java.net/jdk9/jdk9/langtools/file/6ba2130e87bd/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdk8_internals.txt
55
*/
6-
76
predicate jdkInternalApi(string p) {
87
p = "apple.applescript" or
98
p = "apple.laf" or

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
*
44
* http://hg.openjdk.java.net/jdk9/jdk9/langtools/file/6ba2130e87bd/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdkinternals.properties
55
*/
6-
76
predicate jdkInternalReplacement(string old, string new) {
87
exists(string r, int eqIdx | jdkInternalReplacement(r) and eqIdx = r.indexOf("=") |
98
old = r.prefix(eqIdx) and
10-
new = r.suffix(eqIdx+1)
9+
new = r.suffix(eqIdx + 1)
1110
)
1211
}
1312

14-
private
15-
predicate jdkInternalReplacement(string r) {
13+
private predicate jdkInternalReplacement(string r) {
1614
r = "com.sun.crypto.provider.SunJCE=Use java.security.Security.getProvider(provider-name) @since 1.3" or
1715
r = "com.sun.org.apache.xml.internal.security=Use java.xml.crypto @since 1.6" or
1816
r = "com.sun.org.apache.xml.internal.security.utils.Base64=Use java.util.Base64 @since 1.8" or

java/ql/src/Likely Bugs/Comparison/Equality.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class RefiningEquals extends EqualsMethod {
1515
// ... there is a `super` access that ...
1616
exists(MethodAccess sup, SuperAccess qual |
1717
// ... is of the form `super.something`, but not `A.super.something` ...
18-
qual = sup.getQualifier() and not exists(qual.getQualifier()) and
18+
qual = sup.getQualifier() and
19+
not exists(qual.getQualifier()) and
1920
// ... calls `super.equals` ...
2021
sup.getCallee() instanceof EqualsMethod and
2122
// ... on the (only) parameter of this method ...

0 commit comments

Comments
 (0)