Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing semgrep #2304

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions vulnerable-file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ruleid:useless-eqeq
x == x
Copy link

Choose a reason for hiding this comment

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

This expression is always True: x == x or x != x. If testing for floating point NaN, use math.isnan(x), or cmath.isnan(x) if the number is complex. (Line 2)

⚪️ This finding does not block your pull request.
🙈 From python.lang.correctness.useless-eqeq.useless-eqeq.


def __eq__(self, other):
# OK; skip most things that are inside eqs based on what we saw on platform
return self == self and self == other

def sure(ofcourse):
return 1 == 1

class A:
def __eq__(self, other):
# OK; skip most things that are inside eqs based on what we saw on platform
return self == self and self == other


assert(x == x)
assert x == x
assert x == x, "of course"
assertTrue(x ==x)
assertFalse(x == x)