Skip to content

Commit 0e4287e

Browse files
committed
Kotlin: Exclude .kt files from java/unreachable-catch-clause
1 parent 4b042f9 commit 0e4287e

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ predicate overlappingExceptions(RefType e1, RefType e2) {
8686

8787
from TryStmt try, int first, int second, RefType masking, RefType masked, string multiCatchMsg
8888
where
89+
try.getFile().isJavaSourceFile() and
8990
masking = caughtType(try, first) and
9091
masking.getAStrictAncestor() = masked and
9192
masked = caughtType(try, second) and
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
| PartiallyMaskedCatchTest.kt:18:7:20:5 | catch (...) | This catch-clause is unreachable; it is masked $@. | PartiallyMaskedCatchTest.kt:16:7:18:5 | catch (...) | by a previous catch-clause for exceptions of type 'FileNotFoundException' |
2-
| PartiallyMaskedCatchTest.kt:28:7:30:5 | catch (...) | This catch-clause is unreachable; it is masked $@. | PartiallyMaskedCatchTest.kt:26:7:28:5 | catch (...) | by a previous catch-clause for exceptions of type 'FileNotFoundException' |

java/ql/test/kotlin/query-tests/PartiallyMaskedCatch/PartiallyMaskedCatchTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fun fn2() {
1515
fn0()
1616
} catch (e: java.io.FileNotFoundException) {
1717
println(e)
18-
} catch (e: java.io.IOException) { // False positive
18+
} catch (e: java.io.IOException) {
1919
println(e)
2020
}
2121
}
@@ -25,7 +25,7 @@ fun fn3() {
2525
throw java.io.FileNotFoundException()
2626
} catch (e: java.io.FileNotFoundException) {
2727
println(e)
28-
} catch (e: java.io.IOException) { // True positive
28+
} catch (e: java.io.IOException) { // TODO: False negative
2929
println(e)
3030
}
3131
}

0 commit comments

Comments
 (0)