mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Apply suggestions from code review
Co-authored-by: Simon Friis Vindum <paldepind@github.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @name Empty 'if' statement
|
||||
* @description Finds 'if' statements where the "then" branch is empty and no
|
||||
* @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
|
||||
@@ -8,11 +8,11 @@
|
||||
|
||||
import rust
|
||||
|
||||
// find 'if' statements...
|
||||
// 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 exists(ifExpr.getElse())
|
||||
not ifExpr.hasElse()
|
||||
select ifExpr, "This 'if' expression is redundant."
|
||||
|
||||
Reference in New Issue
Block a user