github / codeql

CodeQL: the libraries and queries that power security researchers around the world, as well as code scanning in GitHub Advanced Security
https://codeql.github.com
MIT License
7.67k stars 1.54k forks source link

LGTM.com - false positive - py/missing-equals #8804

Open Rongronggg9 opened 2 years ago

Rongronggg9 commented 2 years ago

Description of the false positive

Talk is cheap, show you the code.

class AbstractClass(abc.ABC):
    def __init__(self):
        self.a = None

class SuperClass(AbstractClass):
    def __init__(self):
        super().__init__()
        self.b = None  # <-- Hey, 'b' is here!

    def __eq__(self, other):
        return type(self) == type(other) and self.a == other.a and self.b == other.b

class SubClass(SuperClass):
     def __init__(self):
        super().__init__()
        self.b = 'b'  # <-- LGTM: The class 'SubClass' does not override '__eq__', but adds the new attribute 'b'.

URL to the alert on the project page on LGTM.com

https://lgtm.com/projects/g/Rongronggg9/RSS-to-Telegram-Bot/snapshot/006cdf55960512e609e7021e4b6785c2d456e3a5/files/src/parsing/medium.py#x1c4917a8f7d52c7f:1

https://lgtm.com/projects/g/Rongronggg9/RSS-to-Telegram-Bot/snapshot/006cdf55960512e609e7021e4b6785c2d456e3a5/files/src/parsing/medium.py#xda2ab04a8ecf9132:1

aeisenberg commented 2 years ago

Indeed, this looks like a false positive. Thank you for reporting it!

Our current focus is on improving our security analysis. Because your report does not relate to a security query, we will put this on our backlog and prioritize it if we get enough reports of the same underlying issue in other projects. If you think that your report is related to our security analysis, please clarify that in a comment. Either way, we'll let you know here as soon as it's fixed!

As you might know, all of our queries are open source. If you do have an idea for a code change, we encourage you to open a pull request. GitHub Code Scanning and lgtm.com have facilities for suppressing individual alerts or disabling a query.