Skip to content

Commit 6c7d848

Browse files
authored
QL: QL: Add query that finds 'if p() then q() else none()'.
1 parent 46789ae commit 6c7d848

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @name Use of 'if' with a 'none()' branch.
3+
* @description Using 'if p() then q() else none()' is bad style. It should be rewritten as 'p() and q()'.
4+
* @kind problem
5+
* @problem.severity warning
6+
* @id ql/if-with-none
7+
* @precision very-high
8+
* @tags maintainability
9+
*/
10+
11+
import ql
12+
13+
from IfFormula ifFormula
14+
where ifFormula.getElsePart() instanceof NoneCall or ifFormula.getThenPart() instanceof NoneCall
15+
select ifFormula, "Use a conjunction instead."

0 commit comments

Comments
 (0)