mirror of
https://github.com/github/codeql.git
synced 2026-02-08 11:11:06 +01:00
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:
15
ql/src/queries/style/IfWithElseNone.ql
Normal file
15
ql/src/queries/style/IfWithElseNone.ql
Normal 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."
|
||||
Reference in New Issue
Block a user