diff options
author | Laura M?dioni <laura.medioni@logilab.fr> | 2015-10-29 14:33:24 +0100 |
---|---|---|
committer | Laura M?dioni <laura.medioni@logilab.fr> | 2015-10-29 14:33:24 +0100 |
commit | 6cfde34cb1b571993fc9b4c7b82ead994f8c7b95 (patch) | |
tree | 80bf1a9bdf034df6b46ec5a4bb666aa2274df871 /pylint/test | |
parent | 928d8b8c9ed8f1d6d2e7cfe5d252c6cde47cff7e (diff) | |
download | pylint-6cfde34cb1b571993fc9b4c7b82ead994f8c7b95.tar.gz |
check the number of boolean expressions in if statement is reasonnable
--max-bool-expr option allows to configure it (by default, up to 5 are
tolerated)
closes issue #677
Diffstat (limited to 'pylint/test')
-rw-r--r-- | pylint/test/functional/too_many_boolean_expressions.py | 20 | ||||
-rw-r--r-- | pylint/test/functional/too_many_boolean_expressions.txt | 4 |
2 files changed, 24 insertions, 0 deletions
diff --git a/pylint/test/functional/too_many_boolean_expressions.py b/pylint/test/functional/too_many_boolean_expressions.py new file mode 100644 index 0000000..b3dc238 --- /dev/null +++ b/pylint/test/functional/too_many_boolean_expressions.py @@ -0,0 +1,20 @@ +"""Checks for if statements containing too many boolean expressions""" + +# pylint: disable=invalid-name + +x = y = z = 5 +if x > -5 and x < 5 and y > -5 and y < 5 and z > -5 and z < 5: # [too-many-boolean-expressions] + pass +elif True and False and 1 and 2 and 3: + pass +elif True and False and 1 and 2 and 3 and 4 and 5: # [too-many-boolean-expressions] + pass +elif True and (True and True) and (x == 5 or True or True): # [too-many-boolean-expressions] + pass +elif True and (True or (x > -5 and x < 5 and (z > -5 or z < 5))): # [too-many-boolean-expressions] + pass +elif True == True == True == True == True == True: + pass + +if True and False and 1 and 2 and 3: + pass diff --git a/pylint/test/functional/too_many_boolean_expressions.txt b/pylint/test/functional/too_many_boolean_expressions.txt new file mode 100644 index 0000000..0bb0086 --- /dev/null +++ b/pylint/test/functional/too_many_boolean_expressions.txt @@ -0,0 +1,4 @@ +too-many-boolean-expressions:6::Too many boolean expressions in if statement (6/5) +too-many-boolean-expressions:10::Too many boolean expressions in if statement (7/5) +too-many-boolean-expressions:12::Too many boolean expressions in if statement (6/5) +too-many-boolean-expressions:14::Too many boolean expressions in if statement (6/5) |