Skip to content

Commit ddfc3bc

Browse files
committed
use set literals instead of big disjunctions
1 parent 830c2dc commit ddfc3bc

File tree

10 files changed

+10
-41
lines changed

10 files changed

+10
-41
lines changed

java/ql/lib/semmle/code/java/frameworks/struts/StrutsConventions.qll

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,7 @@ class Struts2ConventionActionClass extends Class {
101101
exists(string ancestorPackage |
102102
// Has an ancestor package on the whitelist
103103
ancestorPackage = this.getPackage().getName().splitAt(".") and
104-
(
105-
ancestorPackage = "struts" or
106-
ancestorPackage = "struts2" or
107-
ancestorPackage = "action" or
108-
ancestorPackage = "actions"
109-
)
104+
ancestorPackage = ["struts", "struts2", "action", "actions"]
110105
) and
111106
(
112107
this.getName().matches("%" + getConventionSuffix(this)) or

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@ import semmle.code.java.dataflow.SSA
77
* The kind of bound that is known to hold for some variable.
88
*/
99
library class BoundKind extends string {
10-
BoundKind() {
11-
this = "=" or
12-
this = "!=" or
13-
this = ">=" or
14-
this = "<="
15-
}
10+
BoundKind() { this = ["=", "!=", ">=", "<="] }
1611

1712
predicate isEqual() { this = "=" }
1813

python/ql/lib/semmle/python/web/cherrypy/Request.qll

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ class CherryPyRequest extends TaintKind {
1515
}
1616

1717
override TaintKind getTaintOfMethodResult(string name) {
18-
(
19-
name = "getHeader" or
20-
name = "getCookie" or
21-
name = "getUser" or
22-
name = "getPassword"
23-
) and
18+
name in ["getHeader", "getCookie", "getUser", "getPassword"] and
2419
result instanceof ExternalStringKind
2520
}
2621
}

python/ql/lib/semmle/python/web/flask/Request.qll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ class FlaskRequestData extends HttpRequestTaintSource {
1616
FlaskRequestData() {
1717
not this instanceof FlaskRequestArgs and
1818
exists(string name | flask_request_attr(this, name) |
19-
name = "path" or
20-
name = "full_path" or
21-
name = "base_url" or
22-
name = "url"
19+
name in ["path", "full_path", "base_url", "url"]
2320
)
2421
}
2522

python/ql/lib/semmle/python/web/tornado/Request.qll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ class TornadoRequestSource extends HttpRequestTaintSource {
4141
class TornadoExternalInputSource extends HttpRequestTaintSource {
4242
TornadoExternalInputSource() {
4343
exists(string name |
44-
name = "get_argument" or
45-
name = "get_query_argument" or
46-
name = "get_body_argument" or
47-
name = "decode_argument"
44+
name in ["get_argument", "get_query_argument", "get_body_argument", "decode_argument"]
4845
|
4946
this = callToNamedTornadoRequestHandlerMethod(name)
5047
)

python/ql/lib/semmle/python/web/twisted/Request.qll

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ class TwistedRequest extends TaintKind {
1616
}
1717

1818
override TaintKind getTaintOfMethodResult(string name) {
19-
(
20-
name = "getHeader" or
21-
name = "getCookie" or
22-
name = "getUser" or
23-
name = "getPassword"
24-
) and
19+
name in ["getHeader", "getCookie", "getUser", "getPassword"] and
2520
result instanceof ExternalStringKind
2621
}
2722
}

python/ql/src/Expressions/Formatting/AdvancedFormatting.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ library class PossibleAdvancedFormatString extends StrConst {
4040

4141
private predicate implicitlyNumberedField(int start, int end) {
4242
this.field(start, end) and
43-
exists(string c | start + 1 = this.getText().indexOf(c) |
44-
c = "}" or c = ":" or c = "!" or c = "."
45-
)
43+
exists(string c | start + 1 = this.getText().indexOf(c) | c in ["}", ":", "!", "."])
4644
}
4745

4846
/** Whether this format string has implicitly numbered fields */

python/ql/src/Expressions/Regex/DuplicateCharacterInSet.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ predicate duplicate_char_in_class(Regex r, string char) {
3232
//Ignore whitespace in verbose mode
3333
not (
3434
r.getAMode() = "VERBOSE" and
35-
(char = " " or char = "\t" or char = "\r" or char = "\n")
35+
char in [" ", "\t", "\r", "\n"]
3636
)
3737
}
3838

python/ql/src/Statements/ModificationOfLocals.ql

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ predicate modification_of_locals(ControlFlowNode f) {
2222
attr = f.(CallNode).getFunction() and
2323
originIsLocals(attr.getObject(mname))
2424
|
25-
mname = "pop" or
26-
mname = "popitem" or
27-
mname = "update" or
28-
mname = "clear"
25+
mname in ["pop", "popitem", "update", "clear"]
2926
)
3027
}
3128

python/ql/test/library-tests/PointsTo/api/Constants.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ where
77
or
88
txt = "b'" + s + "'" and val = Value::forBytes(s)
99
|
10-
s = "a" or s = "b" or s = "c" or s = "d"
10+
s in ["a", "b", "c", "d"]
1111
)
1212
or
1313
exists(int i | txt = i.toString() and val = Value::forInt(i) |

0 commit comments

Comments
 (0)