Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions its/ruling/src/test/resources/expected/python-S1721.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,6 @@
'project:django-1.4/django/contrib/gis/db/models/proxy.py':[
33,

@alban-auzeill alban-auzeill Dec 22, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is still some FP:

        if condition:
            pass
        elif (geom_value is None) or (geom_value==''):
            pass

],
'project:django-1.4/django/contrib/gis/db/models/sql/compiler.py':[
81,
],
'project:django-1.4/django/contrib/gis/db/models/sql/where.py':[
28,
],
Expand Down Expand Up @@ -514,10 +511,6 @@
'project:django-1.4/django/db/models/base.py':[
423,
],
'project:django-1.4/django/db/models/deletion.py':[
245,
274,
],
'project:django-1.4/django/db/models/fields/files.py':[
217,
],
Expand Down Expand Up @@ -549,7 +542,6 @@
],
'project:django-1.4/django/dispatch/dispatcher.py':[
10,
224,
],
'project:django-1.4/django/dispatch/saferef.py':[
142,
Expand Down Expand Up @@ -752,11 +744,9 @@
],
'project:tornado-2.3/demos/appengine/markdown.py':[
1067,
1497,
],
'project:tornado-2.3/demos/blog/markdown.py':[
1067,
1497,
],
'project:tornado-2.3/tornado/httpclient.py':[
217,
Expand Down Expand Up @@ -1417,9 +1407,6 @@
248,
327,
],
'project:twisted-12.1.0/twisted/web/template.py':[
224,
],
'project:twisted-12.1.0/twisted/web/test/test_http.py':[
901,
902,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void visitNode(AstNode node) {
checkParenthesis(testNodes.get(1), "elif", testNodes.get(1));
}
} else if (node.is(PythonGrammar.FOR_STMT)) {
checkParenthesis(node.getFirstChild(PythonGrammar.EXPRLIST), "for", node);
visitForExpression(node);
checkParenthesis(node.getFirstChild(PythonGrammar.TESTLIST), "in", node);
} else if (node.is(PythonGrammar.RETURN_STMT)) {
checkParenthesis(node.getFirstChild(PythonGrammar.TESTLIST), "return", node);
Expand All @@ -88,6 +88,12 @@ public void visitNode(AstNode node) {
}
}

private void visitForExpression(AstNode node) {
if (node.getFirstChild(PythonGrammar.EXPRLIST).getNumberOfChildren() == 1) {
checkParenthesis(node.getFirstChild(PythonGrammar.EXPRLIST), "for", node);
}
}

private void visitNotTest(AstNode node) {
boolean hasUselessParenthesis = node.select()
.children(PythonGrammar.ATOM)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,11 @@ def func():
if (x > 0 and
x < 3):
pass

my_pairs = [(1, 2), (5, 6)]
names = ['small', 'large']
for (first, second), name in zip(my_pairs, names): # the parenthesis after the "for" keyword is not useless
print(name, first + second)

for (x, y) in foo: # Noncompliant
print(x, y)