Skip to content

Commit bcd11a2

Browse files
committed
Fix simplifiable-duration-constant.ql matching wrong ofSeconds overload
1 parent 06d8d2d commit bcd11a2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

codeql-custom-queries-java/queries/recommendations/simplifiable-duration-constant.ql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ predicate isTimeUnitParam(
138138
exists(string s |
139139
s =
140140
[
141-
"java.util.concurrent.TimeUnit,convert,0,1", "java.lang.Process,waitFor,0,1",
141+
"java.util.concurrent.TimeUnit,convert,0,1",
142+
"java.lang.Process,waitFor,0,1",
142143
"java.nio.channels.AsynchronousChannelGroup,awaitTermination,0,1",
143144
"java.nio.channels.AsynchronousSocketChannel,read,1,2",
144145
"java.nio.channels.AsynchronousSocketChannel,read,3,4",
@@ -204,6 +205,8 @@ predicate simplifiableDurationUsage(IntegerLiteral durationValueExpr, DurationUn
204205
m.getDeclaringType().hasQualifiedName("java.time", "Duration")
205206
|
206207
m.getName() = unitIn.getDurationMethodName() and
208+
// Ignore `ofSeconds(seconds, nanos)` overload and any other future overloads
209+
m.getNumberOfParameters() = 1 and
207210
durationValueExpr = call.getArgument(0)
208211
)
209212
}

0 commit comments

Comments
 (0)