Skip to content

Commit 24000a5

Browse files
authored
Python: Fix bad join in py/redundant-assignment
A minor thing, but still best avoided: ``` Tuple counts for RedundantAssignment::pyflakes_commented_line#bb/2@0477c7 after 14.2s: 160826 ~0% {2} r1 = SCAN py_comments OUTPUT In.2, In.1 160826 ~0% {3} r2 = JOIN r1 WITH project#Files::Location::hasLocationInfo_dispred#bfffff ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Rhs.2 'result' 160826 ~3% {3} r3 = JOIN r2 WITH files_10#join_rhs ON FIRST 1 OUTPUT Lhs.2 'result', Lhs.1, Rhs.1 'file' 46672419 ~4% {4} r4 = JOIN r3 WITH Files::Location::getStartLine_dispred#bf_10#join_rhs ON FIRST 1 OUTPUT Rhs.1, Lhs.2 'file', Lhs.1, Lhs.0 'result' 3951 ~0% {4} r5 = JOIN r4 WITH Files::Location::getFile_dispred#bf ON FIRST 2 OUTPUT Lhs.2, Lhs.3 'result', Lhs.1 'file', toLower(Lhs.2) 0 ~0% {4} r6 = SELECT r5 ON In.3 contains "pyflakes" 0 ~0% {2} r7 = SCAN r6 OUTPUT In.2 'file', In.1 'result' return r7 ```
1 parent c708b6b commit 24000a5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

python/ql/src/Statements/RedundantAssignment.ql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ predicate same_attribute(Attribute a1, Attribute a2) {
7070
not is_property_access(a1)
7171
}
7272

73+
pragma[nomagic]
74+
Comment pyflakes_comment() { result.getText().toLowerCase().matches("%pyflakes%") }
75+
7376
int pyflakes_commented_line(File file) {
74-
exists(Comment c | c.getText().toLowerCase().matches("%pyflakes%") |
75-
c.getLocation().hasLocationInfo(file.getAbsolutePath(), result, _, _, _)
76-
)
77+
pyflakes_comment().getLocation().hasLocationInfo(file.getAbsolutePath(), result, _, _, _)
7778
}
7879

7980
predicate pyflakes_commented(AssignStmt assignment) {

0 commit comments

Comments
 (0)