Skip to content

Commit 6ce0a0d

Browse files
committed
Rust: Add example from the basic-query-for-rust-code.rst.
1 parent 84b5060 commit 6ce0a0d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @name Empty 'if' statement
3+
* @description Finds 'if' statements where the "then" branch is empty and no
4+
* "else" branch exists.
5+
* @id rust/examples/empty-if
6+
* @tags example
7+
*/
8+
9+
import rust
10+
11+
from IfExpr ifExpr
12+
where
13+
ifExpr.getThen().(BlockExpr).getStmtList().getNumberOfStmtOrExpr() = 0 and
14+
not exists(ifExpr.getElse())
15+
select ifExpr, "This 'if' expression is redundant."

0 commit comments

Comments
 (0)