mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
19 lines
481 B
Plaintext
19 lines
481 B
Plaintext
/**
|
|
* @name Empty 'if' expression
|
|
* @description Finds 'if' expressions where the "then" branch is empty and no
|
|
* "else" branch exists.
|
|
* @id rust/examples/empty-if
|
|
* @tags example
|
|
*/
|
|
|
|
import rust
|
|
|
|
// find 'if' expressions...
|
|
from IfExpr ifExpr
|
|
where
|
|
// where the 'then' branch is empty
|
|
ifExpr.getThen().getStmtList().getNumberOfStmtOrExpr() = 0 and
|
|
// and no 'else' branch exists
|
|
not ifExpr.hasElse()
|
|
select ifExpr, "This 'if' expression is redundant."
|