Skip to content

Commit c2a8965

Browse files
committed
Kotlin: Exclude operands of NotNullExpr from NullMaybe query
1 parent e5d7868 commit c2a8965

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

java/ql/src/Likely Bugs/Nullness/NullMaybe.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ from VarAccess access, SsaSourceVariable var, string msg, Expr reason
2121
where
2222
nullDeref(var, access, msg, reason) and
2323
// Exclude definite nulls here, as these are covered by `NullAlways.ql`.
24-
not alwaysNullDeref(var, access)
24+
not alwaysNullDeref(var, access) and
25+
// Exclude operands of `!!` in Kotlin, as `!!` means explicit opt out by the user.
26+
not access.getParent() instanceof NotNullExpr
2527
select access, "Variable $@ may be null here " + msg + ".", var.getVariable(),
2628
var.getVariable().getName(), reason, "this"
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
| 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 |

0 commit comments

Comments
 (0)