Skip to content

Commit 9744cf2

Browse files
committed
Ruby: apply suggested simplification from review
1 parent aaff322 commit 9744cf2

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

ruby/ql/lib/codeql/ruby/frameworks/Array.qll

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ module Array {
287287
(
288288
mc.getNumberOfArguments() = 2 and
289289
(
290-
not exists(mc.getArgument(0).getConstantValue().getInt()) or
291-
not exists(mc.getArgument(1).getConstantValue().getInt())
290+
not mc.getArgument(0).getConstantValue().isInt(_) or
291+
not mc.getArgument(1).getConstantValue().isInt(_)
292292
)
293293
or
294294
mc.getNumberOfArguments() = 1 and
@@ -919,7 +919,7 @@ module Array {
919919
private class InsertUnknownSummary extends InsertSummary {
920920
InsertUnknownSummary() {
921921
this = "insert(index)" and
922-
not exists(mc.getArgument(0).getConstantValue().getInt())
922+
not mc.getArgument(0).getConstantValue().isInt(_)
923923
}
924924

925925
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
@@ -1243,7 +1243,7 @@ module Array {
12431243
RotateUnknownSummary() {
12441244
this = "rotate(index)" and
12451245
exists(mc.getArgument(0)) and
1246-
not exists(mc.getArgument(0).getConstantValue().getInt())
1246+
not mc.getArgument(0).getConstantValue().isInt(_)
12471247
}
12481248

12491249
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
@@ -1298,7 +1298,7 @@ module Array {
12981298
RotateBangUnknownSummary() {
12991299
this = "rotate!(index)" and
13001300
exists(mc.getArgument(0)) and
1301-
not exists(mc.getArgument(0).getConstantValue().getInt())
1301+
not mc.getArgument(0).getConstantValue().isInt(_)
13021302
}
13031303

13041304
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
@@ -1387,7 +1387,7 @@ module Array {
13871387
ShiftArgUnknownSummary() {
13881388
this = "shift(index)" and
13891389
exists(mc.getArgument(0)) and
1390-
not exists(mc.getArgument(0).getConstantValue().getInt())
1390+
not mc.getArgument(0).getConstantValue().isInt(_)
13911391
}
13921392

13931393
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
@@ -1538,8 +1538,8 @@ module Array {
15381538
(
15391539
mc.getNumberOfArguments() = 2 and
15401540
(
1541-
not exists(mc.getArgument(0).getConstantValue().getInt()) or
1542-
not exists(mc.getArgument(1).getConstantValue().getInt())
1541+
not mc.getArgument(0).getConstantValue().isInt(_) or
1542+
not mc.getArgument(1).getConstantValue().isInt(_)
15431543
)
15441544
or
15451545
mc.getNumberOfArguments() = 1 and
@@ -1847,7 +1847,7 @@ module Enumerable {
18471847
private class DropUnknownSummary extends DropSummary {
18481848
DropUnknownSummary() {
18491849
this = "drop(index)" and
1850-
not exists(mc.getArgument(0).getConstantValue().getInt())
1850+
not mc.getArgument(0).getConstantValue().isInt(_)
18511851
}
18521852

18531853
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
@@ -2017,7 +2017,7 @@ module Enumerable {
20172017
FirstArgUnknownSummary() {
20182018
this = "first(?)" and
20192019
mc.getNumberOfArguments() > 0 and
2020-
not exists(mc.getArgument(0).getConstantValue().getInt())
2020+
not mc.getArgument(0).getConstantValue().isInt(_)
20212021
}
20222022

20232023
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
@@ -2411,7 +2411,7 @@ module Enumerable {
24112411
private class TakeUnknownSummary extends TakeSummary {
24122412
TakeUnknownSummary() {
24132413
this = "take(index)" and
2414-
not exists(mc.getArgument(0).getConstantValue().getInt())
2414+
not mc.getArgument(0).getConstantValue().isInt(_)
24152415
}
24162416

24172417
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {

0 commit comments

Comments
 (0)