mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Merge pull request #11290 from tamasvajk/kotlin-autoboxing
Kotlin: Exclude .kt files from autoboxing query
This commit is contained in:
@@ -72,12 +72,16 @@ predicate rebox(Assignment e, Variable v) {
|
||||
|
||||
from Expr e, string conv
|
||||
where
|
||||
boxed(e) and conv = "This expression is implicitly boxed."
|
||||
or
|
||||
unboxed(e) and conv = "This expression is implicitly unboxed."
|
||||
or
|
||||
exists(Variable v | rebox(e, v) |
|
||||
conv =
|
||||
"This expression implicitly unboxes, updates, and reboxes the value of '" + v.getName() + "'."
|
||||
e.getFile().isJavaSourceFile() and
|
||||
(
|
||||
boxed(e) and conv = "This expression is implicitly boxed."
|
||||
or
|
||||
unboxed(e) and conv = "This expression is implicitly unboxed."
|
||||
or
|
||||
exists(Variable v | rebox(e, v) |
|
||||
conv =
|
||||
"This expression implicitly unboxes, updates, and reboxes the value of '" + v.getName() +
|
||||
"'."
|
||||
)
|
||||
)
|
||||
select e, conv
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Violations of Best Practice/legacy/AutoBoxing.ql
|
||||
5
java/ql/test/kotlin/query-tests/AutoBoxing/Test.kt
Normal file
5
java/ql/test/kotlin/query-tests/AutoBoxing/Test.kt
Normal file
@@ -0,0 +1,5 @@
|
||||
fun foo(x: Int?) {
|
||||
if (x != null) {
|
||||
println(x)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user