-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
False Negative π¦No message is emitted but something is wrong with the codeNo message is emitted but something is wrong with the codeGood first issueFriendly and approachable by new contributorsFriendly and approachable by new contributorsHelp wanted πOutside help would be appreciated, good for new contributorsOutside help would be appreciated, good for new contributorsNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation
Description
Current problem
C1802 currently catches this
Examples 1&2 (currently caught by rule C1802)
fruits = ["orange", "apple"]
vegetables = []
if len(fruits):
print(fruits)
if not len(vegetables):
print(vegetables)
I come across the following sometimes as well (potentially in botched attempt to fix the the flagged violation above), which I think should be equally flagged as a violation.
Examples 3&4 (not caught by PLC1802)
fruits = ["orange", "apple"]
vegetables = []
if len(fruits) > 0:
print(fruits)
if len(vegetables) == 0:
print(vegetables)
Examples 5&6 (recommended formulation)
fruits = ["orange", "apple"]
vegetables = []
if fruits:
print(fruits)
if not vegetables:
print(vegetables)
Desired solution
Examples 3&4 to be flagged as well
Additional context
See our previous discussion on this issue.
Metadata
Metadata
Assignees
Labels
False Negative π¦No message is emitted but something is wrong with the codeNo message is emitted but something is wrong with the codeGood first issueFriendly and approachable by new contributorsFriendly and approachable by new contributorsHelp wanted πOutside help would be appreciated, good for new contributorsOutside help would be appreciated, good for new contributorsNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation