Skip to content

Commit b130335

Browse files
authored
Merge pull request #398 from aschackmull/java/autoformat
Approved by yh-semmle
2 parents 0883346 + 41c8947 commit b130335

File tree

20 files changed

+84
-42
lines changed

20 files changed

+84
-42
lines changed

java/ql/src/AlertSuppression.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class SuppressionComment extends Javadoc {
1717
isEolComment(this) and
1818
exists(string text | text = getChild(0).getText() |
1919
// match `lgtm[...]` anywhere in the comment
20-
annotation = text.regexpFind("(?i)\\blgtm\\s*\\[[^\\]]*\\]", _, _) or
20+
annotation = text.regexpFind("(?i)\\blgtm\\s*\\[[^\\]]*\\]", _, _)
21+
or
2122
// match `lgtm` at the start of the comment and after semicolon
2223
annotation = text.regexpFind("(?i)(?<=^|;)\\s*lgtm(?!\\B|\\s*\\[)", _, _).trim()
2324
)

java/ql/src/Frameworks/Spring/Architecture/Refactoring Opportunities/UnusedBean.ql

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,16 @@ class LiveSpringBean extends SpringBean {
156156
// If the class does not exist for this bean, or the class is not a source bean, then this is
157157
// likely to be a definition using a library class, in which case we should consider it to be
158158
// live.
159-
not exists(getClass()) or
160-
not getClass().fromSource() or
159+
not exists(getClass())
160+
or
161+
not getClass().fromSource()
162+
or
161163
// In alfresco, "webscript" beans should be considered live
162-
getBeanParent*().getBeanParentName() = "webscript" or
164+
getBeanParent*().getBeanParentName() = "webscript"
165+
or
163166
// A live child bean implies this bean is live
164-
exists(LiveSpringBean child | this = child.getBeanParent()) or
167+
exists(LiveSpringBean child | this = child.getBeanParent())
168+
or
165169
// Beans constructed by a bean factory are considered live
166170
exists(SpringBeanFactory beanFactory | this = beanFactory.getAConstructedBean())
167171
)

java/ql/src/Likely Bugs/Concurrency/NonSynchronizedOverride.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ predicate delegatingOverride(Method sub, Method sup) {
4141
stmt = sub.getBody().(SingletonBlock).getStmt() and
4242
(
4343
// ...that is either a delegating call to `sup` (with a possible cast)...
44-
delegatingSuperCall(stmt.(ExprStmt).getExpr(), sup) or
44+
delegatingSuperCall(stmt.(ExprStmt).getExpr(), sup)
45+
or
4546
// ...or a `return` statement containing such a call.
4647
delegatingSuperCall(stmt.(ReturnStmt).getResult(), sup)
4748
)

java/ql/src/Security/CWE/CWE-129/BoundingChecks.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ predicate lessthanLength(ArrayAccess a) {
5858
pragma[nomagic]
5959
private Expr arrayReference(ArrayAccess arrayAccess) {
6060
// Array is stored in a variable.
61-
result = arrayAccess.getArray().(VarAccess).getVariable().getAnAccess() or
61+
result = arrayAccess.getArray().(VarAccess).getVariable().getAnAccess()
62+
or
6263
// Array is returned from a method.
6364
result.(MethodAccess).getMethod() = arrayAccess.getArray().(MethodAccess).getMethod()
6465
}

java/ql/src/Security/CWE/CWE-129/ImproperValidationOfArrayIndexCodeSpecified.ql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ where
3232
not (
3333
(
3434
// The input has a lower bound.
35-
source.lowerBound() >= 0 or
35+
source.lowerBound() >= 0
36+
or
3637
// There is a condition dominating this expression ensuring that the index is >= 0.
3738
lowerBound(arrayAccess.getIndexExpr()) >= 0
3839
) and
3940
(
4041
// The input has an upper bound, and the array has a fixed size, and that fixed size is less.
41-
source.upperBound() < fixedArraySize(arrayAccess) or
42+
source.upperBound() < fixedArraySize(arrayAccess)
43+
or
4244
// There is a condition dominating this expression that ensures the index is less than the length.
4345
lessthanLength(arrayAccess)
4446
)

java/ql/src/Security/CWE/CWE-319/HttpsUrls.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class HTTPString extends StringLiteral {
1818
exists(string s | this.getRepresentedString() = s |
1919
(
2020
// Either the literal "http", ...
21-
s = "http" or
21+
s = "http"
22+
or
2223
// ... or the beginning of a http URL.
2324
s.matches("http://%")
2425
) and

java/ql/src/semmle/code/java/Expr.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,8 @@ class VarAccess extends Expr, @varaccess {
12661266
*/
12671267
predicate isLocal() {
12681268
// The access has no qualifier, or...
1269-
not hasQualifier() or
1269+
not hasQualifier()
1270+
or
12701271
// the qualifier is either `this` or `A.this`, where `A` is the enclosing type, or
12711272
// the qualifier is either `super` or `A.super`, where `A` is the enclosing type.
12721273
getQualifier().(InstanceAccess).isOwnInstanceAccess()
@@ -1705,7 +1706,8 @@ class Argument extends Expr {
17051706
p.isVarargs() and
17061707
ptyp = p.getType() and
17071708
(
1708-
hasSubtype*(ptyp, typ) or
1709+
hasSubtype*(ptyp, typ)
1710+
or
17091711
// If the types don't match then we'll guess based on whether there are type variables involved.
17101712
hasInstantiation(ptyp.(Array).getComponentType())
17111713
)

java/ql/src/semmle/code/java/Member.qll

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ class Method extends Callable, @method {
370370
}
371371

372372
override predicate isStrictfp() {
373-
Callable.super.isStrictfp() or
373+
Callable.super.isStrictfp()
374+
or
374375
// JLS 8.1.1.3, JLS 9.1.1.2
375376
getDeclaringType().isStrictfp()
376377
}
@@ -575,21 +576,24 @@ class Field extends Member, ExprParent, @field, Variable {
575576
predicate isSourceDeclaration() { this.getSourceDeclaration() = this }
576577

577578
override predicate isPublic() {
578-
Member.super.isPublic() or
579+
Member.super.isPublic()
580+
or
579581
// JLS 9.3: Every field declaration in the body of an interface is
580582
// implicitly public, static, and final
581583
getDeclaringType() instanceof Interface
582584
}
583585

584586
override predicate isStatic() {
585-
Member.super.isStatic() or
587+
Member.super.isStatic()
588+
or
586589
// JLS 9.3: Every field declaration in the body of an interface is
587590
// implicitly public, static, and final
588591
this.getDeclaringType() instanceof Interface
589592
}
590593

591594
override predicate isFinal() {
592-
Member.super.isFinal() or
595+
Member.super.isFinal()
596+
or
593597
// JLS 9.3: Every field declaration in the body of an interface is
594598
// implicitly public, static, and final
595599
this.getDeclaringType() instanceof Interface

java/ql/src/semmle/code/java/Reflection.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,11 @@ class NewInstance extends MethodAccess {
271271
not result instanceof TypeVariable and
272272
(
273273
// If this is called on a `Class<T>` instance, return the inferred type `T`.
274-
result = inferClassParameterType(getQualifier()) or
274+
result = inferClassParameterType(getQualifier())
275+
or
275276
// If this is called on a `Constructor<T>` instance, return the inferred type `T`.
276-
result = inferConstructorParameterType(getQualifier()) or
277+
result = inferConstructorParameterType(getQualifier())
278+
or
277279
// If the result of this is cast to a particular type, then use that type.
278280
result = getCastInferredConstructedTypes()
279281
)

java/ql/src/semmle/code/java/Type.qll

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,19 @@ private predicate typeArgumentContainsAux1(RefType s, RefType t, int n) {
216216
|
217217
exists(RefType tUpperBound | tUpperBound = t.(Wildcard).getUpperBound().getType() |
218218
// ? extends T <= ? extends S if T <: S
219-
hasSubtypeStar0(s.(Wildcard).getUpperBound().getType(), tUpperBound) or
219+
hasSubtypeStar0(s.(Wildcard).getUpperBound().getType(), tUpperBound)
220+
or
220221
// ? extends T <= ?
221222
s.(Wildcard).isUnconstrained()
222223
)
223224
or
224225
exists(RefType tLowerBound | tLowerBound = t.(Wildcard).getLowerBound().getType() |
225226
// ? super T <= ? super S if s <: T
226-
hasSubtypeStar0(tLowerBound, s.(Wildcard).getLowerBound().getType()) or
227+
hasSubtypeStar0(tLowerBound, s.(Wildcard).getLowerBound().getType())
228+
or
227229
// ? super T <= ?
228-
s.(Wildcard).isUnconstrained() or
230+
s.(Wildcard).isUnconstrained()
231+
or
229232
// ? super T <= ? extends Object
230233
wildcardExtendsObject(s)
231234
)
@@ -736,13 +739,15 @@ class NestedType extends RefType {
736739
}
737740

738741
override predicate isPublic() {
739-
super.isPublic() or
742+
super.isPublic()
743+
or
740744
// JLS 9.5: A member type declaration in an interface is implicitly public and static
741745
exists(Interface i | this = i.getAMember())
742746
}
743747

744748
override predicate isStrictfp() {
745-
super.isStrictfp() or
749+
super.isStrictfp()
750+
or
746751
// JLS 8.1.1.3, JLS 9.1.1.2
747752
getEnclosingType().isStrictfp()
748753
}
@@ -762,11 +767,14 @@ class NestedType extends RefType {
762767
* section 8.9 (Enums) and section 9.5 (Member Type Declarations).
763768
*/
764769
override predicate isStatic() {
765-
super.isStatic() or
770+
super.isStatic()
771+
or
766772
// JLS 8.5.1: A member interface is implicitly static.
767-
this instanceof Interface or
773+
this instanceof Interface
774+
or
768775
// JLS 8.9: A nested enum type is implicitly static.
769-
this instanceof EnumType or
776+
this instanceof EnumType
777+
or
770778
// JLS 9.5: A member type declaration in an interface is implicitly public and static
771779
exists(Interface i | this = i.getAMember())
772780
}

0 commit comments

Comments
 (0)