diff options
Diffstat (limited to 'doc/data/messages')
7 files changed, 17 insertions, 18 deletions
diff --git a/doc/data/messages/c/compare-to-zero/bad.py b/doc/data/messages/c/compare-to-zero/bad.py deleted file mode 100644 index c987403a4..000000000 --- a/doc/data/messages/c/compare-to-zero/bad.py +++ /dev/null @@ -1,8 +0,0 @@ -x = 0 -y = 1 - -if x == 0: # [compare-to-zero] - print("x is equal to zero") - -if y != 0: # [compare-to-zero] - print("y is not equal to zero") diff --git a/doc/data/messages/c/compare-to-zero/good.py b/doc/data/messages/c/compare-to-zero/good.py deleted file mode 100644 index bea3733e2..000000000 --- a/doc/data/messages/c/compare-to-zero/good.py +++ /dev/null @@ -1,8 +0,0 @@ -x = 0 -y = 1 - -if not x: - print("x is equal to zero") - -if y: - print("y is not equal to zero") diff --git a/doc/data/messages/c/compare-to-zero/pylintrc b/doc/data/messages/c/compare-to-zero/pylintrc deleted file mode 100644 index 895291f84..000000000 --- a/doc/data/messages/c/compare-to-zero/pylintrc +++ /dev/null @@ -1,2 +0,0 @@ -[main] -load-plugins=pylint.extensions.comparetozero diff --git a/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-zero/bad.py b/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-zero/bad.py new file mode 100644 index 000000000..2f93afd31 --- /dev/null +++ b/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-zero/bad.py @@ -0,0 +1,6 @@ +def important_math(x: int, y: int) -> None: + if x == 0: # [use-implicit-booleaness-not-comparison-to-zero] + print("x is equal to zero") + + if y != 0: # [use-implicit-booleaness-not-comparison-to-zero] + print("y is not equal to zero") diff --git a/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-zero/details.rst b/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-zero/details.rst new file mode 100644 index 000000000..670633b2a --- /dev/null +++ b/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-zero/details.rst @@ -0,0 +1,3 @@ +Following this check blindly in weakly typed code base can create hard to debug issues. If the value +can be something else that is falsey but not an ``int`` (for example ``None``, or an empty string), +the code will not be equivalent. diff --git a/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-zero/good.py b/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-zero/good.py new file mode 100644 index 000000000..feae7fe30 --- /dev/null +++ b/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-zero/good.py @@ -0,0 +1,6 @@ +def important_math(x: int, y: int) -> None: + if not x: + print("x is equal to zero") + + if y: + print("y is not equal to zero") diff --git a/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-zero/pylintrc b/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-zero/pylintrc new file mode 100644 index 000000000..43d8bd751 --- /dev/null +++ b/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-zero/pylintrc @@ -0,0 +1,2 @@ +[main] +enable=use-implicit-booleaness-not-comparison-to-zero |