Files
codeql/python/ql/examples/snippets/conditional_expression.ql
Taus Brock-Nannestad f07a7bf8cf Python: Autoformat everything using qlformat.
Will need subsequent PRs fixing up test failures (due to deprecated
methods moving around), but other than that everything should be
straight-forward.
2020-07-07 15:43:52 +02:00

19 lines
460 B
Plaintext

/**
* @id py/examples/conditional-expression
* @name Conditional expressions
* @description Finds conditional expressions of the form '... if ... else ...'
* where the classes of the sub-expressions differ
* @tags conditional
* expression
* ternary
*/
import python
from IfExp e, ClassObject cls1, ClassObject cls2
where
e.getBody().refersTo(_, cls1, _) and
e.getOrelse().refersTo(_, cls2, _) and
cls1 != cls2
select e