Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a new check,
self-assigning-variable
This check is emitted when we detect that a variable is assigned to itself, which might indicate a potential bug in the code application. Close #2930
- Loading branch information
1 parent
a636569
commit a0d2af8
Showing
6 changed files
with
82 additions
and
1 deletion.
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
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,20 @@ | ||
# pylint: disable=missing-docstring,too-few-public-methods | ||
# pylint: disable=unpacking-non-sequence,attribute-defined-outside-init,invalid-name | ||
|
||
class Class: | ||
pass | ||
|
||
CLS = Class() | ||
FIRST = 1 | ||
# Not enough values on the right hand side | ||
FIRST, SECOND = FIRST | ||
# Not enough values on the left hand side | ||
FIRST = FIRST, SECOND | ||
# Not equivalent to a self assignment | ||
FIRST = (FIRST, ) | ||
# Not assigning to an attribute | ||
CLS.FIRST = FIRST | ||
# Not a name on the right hand side | ||
FIRST = Class() | ||
FIRST = FIRST # [self-assigning-variable] | ||
FIRST, SECOND = FIRST, CLS.FIRST # [self-assigning-variable] |
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,2 @@ | ||
self-assigning-variable:19::Assigning the same variable 'FIRST' to itself | ||
self-assigning-variable:20::Assigning the same variable 'FIRST' to itself |
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