Skip to content

Commit

Permalink
Write-only container query: account for implicitly-initialised variables
Browse files Browse the repository at this point in the history
  • Loading branch information
smowton committed Nov 30, 2023
1 parent bb6e044 commit 9177409
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions java/ql/src/Likely Bugs/Collections/WriteOnlyContainer.ql
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ where
) and
// Also, any value that `v` is initialized to is a new container,
forall(Expr e | e = v.getAnAssignedValue() | e instanceof ClassInstanceExpr) and
// and `v` is not implicitly initialized by a for-each loop.
not exists(EnhancedForStmt efs | efs.getVariable().getVariable() = v)
// and `v` is not implicitly initialized
not v.(LocalVariableDecl).getDeclExpr().hasImplicitInit()
select v, "The contents of this container are never accessed."

0 comments on commit 9177409

Please sign in to comment.