mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Merge pull request #10949 from tamasvajk/kotlin-underscore-var
Kotlin: exclude Kotlin files from `java/underscore-identifier`
This commit is contained in:
@@ -22,7 +22,7 @@ class IdentifierElement extends Element {
|
||||
|
||||
from IdentifierElement e, string msg
|
||||
where
|
||||
e.fromSource() and
|
||||
e.getCompilationUnit().isJavaSourceFile() and
|
||||
not e.(Constructor).isDefaultConstructor() and
|
||||
(
|
||||
e.getName() = "_" and
|
||||
|
||||
11
java/ql/test/kotlin/query-tests/UnderscoreIdentifier/Test.kt
Normal file
11
java/ql/test/kotlin/query-tests/UnderscoreIdentifier/Test.kt
Normal file
@@ -0,0 +1,11 @@
|
||||
fun fn() {
|
||||
try {
|
||||
val l = listOf(1, 2, 3)
|
||||
l.forEachIndexed { index, _ -> println(index) }
|
||||
|
||||
val p = Pair(1, 2)
|
||||
val (first, _) = p
|
||||
} catch (_: Exception) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Compatibility/JDK9/UnderscoreIdentifier.ql
|
||||
@@ -0,0 +1,7 @@
|
||||
| Test.kt:3:9:3:31 | List<Integer> l |
|
||||
| Test.kt:4:28:4:32 | index |
|
||||
| Test.kt:4:35:4:35 | p1 |
|
||||
| Test.kt:6:9:6:26 | Pair<Integer,Integer> p |
|
||||
| Test.kt:7:14:7:18 | int first |
|
||||
| Test.kt:7:26:7:26 | Pair<Integer,Integer> tmp0_container |
|
||||
| Test.kt:8:14:8:25 | Exception _ |
|
||||
@@ -0,0 +1,3 @@
|
||||
import java
|
||||
|
||||
query predicate variables(Variable v) { v.fromSource() }
|
||||
Reference in New Issue
Block a user