Merge pull request #62 from github/if-with-none

QL: Add query that finds 'if p() then q() else none()'
This commit is contained in:
Mathias Vorreiter Pedersen
2021-10-13 14:29:15 +01:00
committed by GitHub

View File

@@ -0,0 +1,15 @@
/**
* @name Use of 'if' with a 'none()' branch.
* @description Using 'if p() then q() else none()' is bad style. It should be rewritten as 'p() and q()'.
* @kind problem
* @problem.severity warning
* @id ql/if-with-none
* @precision very-high
* @tags maintainability
*/
import ql
from IfFormula ifFormula
where ifFormula.getElsePart() instanceof NoneCall or ifFormula.getThenPart() instanceof NoneCall
select ifFormula, "Use a conjunction instead."