Skip to content

Commit dfc72ed

Browse files
authored
Merge pull request github#11302 from tamasvajk/kotlin-ignored-return
Kotlin: Exclude .kt files from ignored return value query
2 parents ad7c0f9 + c426637 commit dfc72ed

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

java/ql/src/Likely Bugs/Statements/ReturnValueIgnored.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ predicate isMustBeQualifierMockingMethod(Method m) {
7575

7676
predicate relevantMethodCall(MethodAccess ma, Method m) {
7777
// For "return value ignored", all method calls are relevant.
78+
not ma.getFile().isKotlinSourceFile() and
7879
ma.getMethod() = m and
7980
not m.getReturnType().hasName("void") and
8081
(not isMockingMethod(m) or isMustBeQualifierMockingMethod(m)) and

java/ql/test/kotlin/query-tests/ReturnValueIgnored/ReturnValueIgnored.expected

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Likely Bugs/Statements/ReturnValueIgnored.ql
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Foo {
2+
fun foo(): Int { return 5 }
3+
fun bar() {
4+
val x0 = foo()
5+
val x1 = foo()
6+
val x2 = foo()
7+
val x3 = foo()
8+
val x4 = foo()
9+
val x5 = foo()
10+
val x6 = foo()
11+
val x7 = foo()
12+
val x8 = foo()
13+
val x9 = foo()
14+
val x = if (true) { foo() } else 6
15+
}
16+
}

0 commit comments

Comments
 (0)