Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ae8dbd8

Browse files
committed
Python: Update test-file for py/redundant-assignment
now the test code can be pasted, and actually works ;)
1 parent 3816688 commit ae8dbd8

3 files changed

Lines changed: 17 additions & 13 deletions

File tree

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
| 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 |
2-
| 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 |
3-
| 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 |
4-
| 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 |
2+
| 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 |
3+
| 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 |
4+
| 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 |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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 |
1+
| 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 |

python/ql/test/query-tests/Statements/general/statements_test.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,19 @@ def __init__(self, args):
6464
func(x)
6565
else:
6666
do_something()
67-
67+
6868
while x < 10:
6969
func(x)
7070
else:
7171
do_something()
72-
72+
7373
#OK else clauses:
7474
for x in range(10):
7575
if func(x):
7676
break
7777
else:
7878
do_something()
79-
79+
8080
while x < 10:
8181
if func(x):
8282
break
@@ -95,24 +95,24 @@ def __init__(self, args):
9595

9696
#Not a redundant assignment if a property.
9797
class WithProp(object):
98-
98+
9999
@property
100100
def x(self):
101101
return self._x
102-
102+
103103
@prop.setter
104104
def set_x(self, x):
105105
side_effect(x)
106106
self._x = x
107-
107+
108108
def meth(self):
109109
self.x = self.x
110-
110+
111111
def maybe_property(x):
112112
x.y = x.y
113-
113+
114114
class WithoutProp(object):
115-
115+
116116
def meth(self):
117117
self.x = self.x
118118

@@ -143,8 +143,12 @@ class EnumDerived(Enum):
143143

144144
class SideEffectingAttr(object):
145145

146+
def __init__(self):
147+
self.foo = 'foo'
148+
146149
def __setattr__(self, name, val):
147150
print("hello!")
151+
super().__setattr__(name, val)
148152

149153
s = SideEffectingAttr()
150154
s.foo = s.foo

0 commit comments

Comments
 (0)