-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[16.6.0] Add B002, B301, B302, B303, B304, B305
- Loading branch information
Showing
7 changed files
with
278 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ | |
], | ||
entry_points={ | ||
'flake8.extension': [ | ||
'B00 = bugbear:BugBearChecker', | ||
'B = bugbear:BugBearChecker', | ||
], | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
Should emit: | ||
B002 - on lines 13 and 17 | ||
""" | ||
|
||
def this_is_all_fine(n): | ||
x = n + 1 | ||
y = 1 + n | ||
z = + x + y | ||
return +z | ||
|
||
def this_is_buggy(n): | ||
x = ++n | ||
return x | ||
|
||
def this_is_buggy_too(n): | ||
return (+ | ||
+n | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
Should emit: | ||
B301 - on lines 33-36 | ||
B302 - on lines 37-40 | ||
B305 - on lines 37-40 | ||
""" | ||
|
||
import builtins # future's builtins really | ||
import future.utils | ||
import six | ||
from six import iterkeys | ||
from future.utils import itervalues | ||
|
||
def this_is_okay(): | ||
d = {} | ||
iterkeys(d) | ||
six.iterkeys(d) | ||
six.itervalues(d) | ||
six.iteritems(d) | ||
six.iterlists(d) | ||
six.viewkeys(d) | ||
six.viewvalues(d) | ||
six.viewlists(d) | ||
itervalues(d) | ||
future.utils.iterkeys(d) | ||
future.utils.itervalues(d) | ||
future.utils.iteritems(d) | ||
future.utils.iterlists(d) | ||
future.utils.viewkeys(d) | ||
future.utils.viewvalues(d) | ||
future.utils.viewlists(d) | ||
six.next(d) | ||
builtins.next(d) | ||
|
||
def everything_else_is_wrong(): | ||
d = None # note: bugbear is no type checker | ||
d.iterkeys() | ||
d.itervalues() | ||
d.iteritems() | ||
d.iterlists() # Djangoism | ||
d.viewkeys() | ||
d.viewvalues() | ||
d.viewitems() | ||
d.viewlists() # Djangoism | ||
d.next() | ||
d.keys().next() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
""" | ||
Should emit: | ||
B303 - on line 21 | ||
B304 - on line 28 | ||
""" | ||
|
||
import sys | ||
import something_else | ||
|
||
def this_is_okay(): | ||
something_else.maxint | ||
maxint = 3 | ||
maxint | ||
|
||
maxint = 3 | ||
|
||
def this_is_also_okay(): | ||
maxint | ||
|
||
class CustomClassWithBrokenMetaclass: | ||
__metaclass__ = type | ||
maxint = 5 # this is okay | ||
|
||
def this_is_also_fine(self): | ||
self.maxint | ||
|
||
def this_is_wrong(): | ||
sys.maxint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters