Files
codeql/java/ql/examples/ternaryconditional.ql
2019-07-26 17:47:11 +02:00

16 lines
441 B
Plaintext

/**
* @name Conditional expressions
* @description Finds conditional expressions of the form '... ? ... : ...'
* where the types of the resulting expressions differ
* @tags conditional
* type
*/
import java
from ConditionalExpr e
where e.getTrueExpr().getType() != e.getFalseExpr().getType()
and not e.getTrueExpr().getType() instanceof NullType
and not e.getFalseExpr().getType() instanceof NullType
select e