-
-
Save erik-krogh/b31a6afa616df3a93420907acd54978a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @name Using exists instead of a cast | |
* @description TODO | |
* @kind problem | |
* @problem.severity warning | |
* @id ql/exists-instead-of-cast | |
* @precision high | |
*/ | |
import ql | |
from Exists ex, ComparisonFormula comp, AstNode operand, AstNode formula | |
where | |
count(ex.getArgument(_)) = 1 and | |
exists(ex.getRange()) and | |
exists(ex.getFormula()) and | |
comp = ex.getRange() and | |
comp.getOperator() = "=" and | |
comp.getAnOperand().(VarAccess).getDeclaration() = ex.getArgument(0) and | |
not operand.(VarAccess).getDeclaration() = ex.getArgument(0) and | |
operand = comp.getAnOperand() and | |
count(VarAccess access | access.getDeclaration() = ex.getArgument(0)) = 2 and | |
formula = ex.getFormula() | |
select ex, "This exists can be simplfied to a cast of $@ to " + ex.getArgument(0).getType().getName() + ".", operand, "the operand" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment