mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
Python: Update test-file for py/redundant-assignment
now the test code can be pasted, and actually works ;)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
| statements_test.py:19:5:19:18 | AssignStmt | Left hand side of assignment contains 3 variables, but right hand side is a $@ of length 2. | statements_test.py:19:15:19:18 | statements_test.py:19 | tuple |
|
||||
| statements_test.py:163:5:163:23 | AssignStmt | Left hand side of assignment contains 3 variables, but right hand side is a $@ of length 5. | statements_test.py:163:13:163:23 | statements_test.py:163 | list |
|
||||
| statements_test.py:172:5:172:48 | AssignStmt | Left hand side of assignment contains 3 variables, but right hand side is a $@ of length 5. | statements_test.py:167:16:167:24 | statements_test.py:167 | tuple |
|
||||
| statements_test.py:172:5:172:48 | AssignStmt | Left hand side of assignment contains 3 variables, but right hand side is a $@ of length 6. | statements_test.py:169:16:169:26 | statements_test.py:169 | tuple |
|
||||
| statements_test.py:167:5:167:23 | AssignStmt | Left hand side of assignment contains 3 variables, but right hand side is a $@ of length 5. | statements_test.py:167:13:167:23 | statements_test.py:167 | list |
|
||||
| statements_test.py:176:5:176:48 | AssignStmt | Left hand side of assignment contains 3 variables, but right hand side is a $@ of length 5. | statements_test.py:171:16:171:24 | statements_test.py:171 | tuple |
|
||||
| statements_test.py:176:5:176:48 | AssignStmt | Left hand side of assignment contains 3 variables, but right hand side is a $@ of length 6. | statements_test.py:173:16:173:26 | statements_test.py:173 | tuple |
|
||||
|
||||
@@ -1 +1 @@
|
||||
| statements_test.py:181:5:181:9 | Delete | Unnecessary deletion of local variable $@ in function $@. | statements_test.py:181:9:181:9 | statements_test.py:181 | x | statements_test.py:179:1:179:31 | statements_test.py:179 | error_unnecessary_delete |
|
||||
| statements_test.py:185:5:185:9 | Delete | Unnecessary deletion of local variable $@ in function $@. | statements_test.py:185:9:185:9 | statements_test.py:185 | x | statements_test.py:183:1:183:31 | statements_test.py:183 | error_unnecessary_delete |
|
||||
|
||||
@@ -64,19 +64,19 @@ for x in range(10):
|
||||
func(x)
|
||||
else:
|
||||
do_something()
|
||||
|
||||
|
||||
while x < 10:
|
||||
func(x)
|
||||
else:
|
||||
do_something()
|
||||
|
||||
|
||||
#OK else clauses:
|
||||
for x in range(10):
|
||||
if func(x):
|
||||
break
|
||||
else:
|
||||
do_something()
|
||||
|
||||
|
||||
while x < 10:
|
||||
if func(x):
|
||||
break
|
||||
@@ -95,24 +95,24 @@ else:
|
||||
|
||||
#Not a redundant assignment if a property.
|
||||
class WithProp(object):
|
||||
|
||||
|
||||
@property
|
||||
def x(self):
|
||||
return self._x
|
||||
|
||||
|
||||
@prop.setter
|
||||
def set_x(self, x):
|
||||
side_effect(x)
|
||||
self._x = x
|
||||
|
||||
|
||||
def meth(self):
|
||||
self.x = self.x
|
||||
|
||||
|
||||
def maybe_property(x):
|
||||
x.y = x.y
|
||||
|
||||
|
||||
class WithoutProp(object):
|
||||
|
||||
|
||||
def meth(self):
|
||||
self.x = self.x
|
||||
|
||||
@@ -143,8 +143,12 @@ for e in EnumDerived:
|
||||
|
||||
class SideEffectingAttr(object):
|
||||
|
||||
def __init__(self):
|
||||
self.foo = 'foo'
|
||||
|
||||
def __setattr__(self, name, val):
|
||||
print("hello!")
|
||||
super().__setattr__(name, val)
|
||||
|
||||
s = SideEffectingAttr()
|
||||
s.foo = s.foo
|
||||
|
||||
Reference in New Issue
Block a user