Skip to content

Commit f86011f

Browse files
committed
Python: Document RedundantComparison.qll.
1 parent 2f93b14 commit f86011f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

python/ql/src/Expressions/RedundantComparison.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
/** Helper functions for queries having to do with redundant comparisons. */
2+
13
import python
24

5+
/** A comparison where the left and right hand sides appear to be identical. */
36
class RedundantComparison extends Compare {
47
RedundantComparison() {
58
exists(Expr left, Expr right |
@@ -8,6 +11,15 @@ class RedundantComparison extends Compare {
811
)
912
}
1013

14+
/** Holds if this comparison could be due to a missing `self.`, for example
15+
* ```python
16+
* foo == foo
17+
* ```
18+
* instead of
19+
* ```python
20+
* self.foo == foo
21+
* ```
22+
*/
1123
predicate maybeMissingSelf() {
1224
exists(Name left |
1325
this.compares(left, _, _) and

0 commit comments

Comments
 (0)