Merge pull request #11290 from tamasvajk/kotlin-autoboxing

Kotlin: Exclude .kt files from autoboxing query
This commit is contained in:
Tamás Vajk
2022-11-16 13:56:29 +01:00
committed by GitHub
4 changed files with 17 additions and 7 deletions

View File

@@ -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

View File

@@ -0,0 +1 @@
Violations of Best Practice/legacy/AutoBoxing.ql

View File

@@ -0,0 +1,5 @@
fun foo(x: Int?) {
if (x != null) {
println(x)
}
}