Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Issue 29634555: NoIssue - Detect redundant comparisons

Created:
Dec. 10, 2017, 6:10 p.m. by rosie
Modified:
Jan. 14, 2018, 1:45 a.m.
Reviewers:
Sebastian Noack
CC:
tlucas, Vasily Kuznetsov
Base URL:
https://hg.adblockplus.org/codingtools
Visibility:
Public.

Description

NoIssue - Detect redundant comparisons `a == 1 or a == 2` should be `a in {1, 2}` `a != 1 and a != 2` should be `a not in {1, 2}`

Patch Set 1 #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+49 lines, -1 line) Patch
M flake8-eyeo/README.md View 1 chunk +1 line, -0 lines 0 comments Download
M flake8-eyeo/flake8_eyeo.py View 2 chunks +31 lines, -1 line 3 comments Download
A flake8-eyeo/tests/A208.py View 1 chunk +17 lines, -0 lines 1 comment Download

Messages

Total messages: 2
rosie
Dec. 10, 2017, 6:10 p.m. (2017-12-10 18:10:10 UTC) #1
Sebastian Noack
Dec. 10, 2017, 11:19 p.m. (2017-12-10 23:19:57 UTC) #2
https://codereview.adblockplus.org/29634555/diff/29634556/flake8-eyeo/flake8_...
File flake8-eyeo/flake8_eyeo.py (right):

https://codereview.adblockplus.org/29634555/diff/29634556/flake8-eyeo/flake8_...
flake8-eyeo/flake8_eyeo.py:293: right = node.values[1]
What if there is another condition in between? E.g: x == 1 or y or x == 2

https://codereview.adblockplus.org/29634555/diff/29634556/flake8-eyeo/flake8_...
flake8-eyeo/flake8_eyeo.py:297: isinstance(left.ops[0], ast.Eq) or
This expression is the same as the left-hand side of the and-operator.

https://codereview.adblockplus.org/29634555/diff/29634556/flake8-eyeo/flake8_...
flake8-eyeo/flake8_eyeo.py:303: if isinstance(left.left, ast.Name):
What if it is an Attribute node? E.g: x.a == 1 or x.a == 2

https://codereview.adblockplus.org/29634555/diff/29634556/flake8-eyeo/tests/A...
File flake8-eyeo/tests/A208.py (right):

https://codereview.adblockplus.org/29634555/diff/29634556/flake8-eyeo/tests/A...
flake8-eyeo/tests/A208.py:12: if a != 1 or 2 != a:
This expression will always evaluate to True. I suppose you meant `a != 1 and a
!= 2` which could be written as `a not in {1, 2}`.

Powered by Google App Engine
This is Rietveld