Kotlin: Exclude operands of NotNullExpr from NullMaybe query

This commit is contained in:
Tamas Vajk
2022-05-13 13:42:07 +02:00
parent e5d78687aa
commit c2a8965c90
2 changed files with 3 additions and 2 deletions

View File

@@ -21,6 +21,8 @@ from VarAccess access, SsaSourceVariable var, string msg, Expr reason
where
nullDeref(var, access, msg, reason) and
// Exclude definite nulls here, as these are covered by `NullAlways.ql`.
not alwaysNullDeref(var, access)
not alwaysNullDeref(var, access) and
// Exclude operands of `!!` in Kotlin, as `!!` means explicit opt out by the user.
not access.getParent() instanceof NotNullExpr
select access, "Variable $@ may be null here " + msg + ".", var.getVariable(),
var.getVariable().getName(), reason, "this"

View File

@@ -1 +0,0 @@
| Test.kt:6:13:6:13 | d | Variable $@ may be null here because of $@ assignment. | Test.kt:2:5:2:25 | Double d | d | Test.kt:2:5:2:25 | d | this |