S1144 False Positive when method referenced with variable other than self

Please provide

  • Operating system: MacOS 10.15.7 (19H1615)
  • SonarLint plugin version: 7.4.0.60471
  • Programming language you’re coding in: Python 3.11.1
  • Is connected mode used: No
    • Connected to SonarCloud or SonarQube (and which version): N/A
class LinkedListNode:
    def __init__(self):
        self.next = None
        self.prev = None

    def __insert_next(self, node):
        node.next = self.next
        node.prev = self
        self.next.prev = node
        self.next = node

    def add_after_first_node(self, node, new_node):
        while node.prev is not None:
            node = node.prev
        node.__insert_next(new_node)

Expected: No issues reported.

Actual:
For the last line in the code snippet above, sonarlint reports:

Remove this unused class-private ‘__insert_next’ method.

If the last line is changed to:

        self.__insert_next(new_node)

then the issue goes away.

Hello @rossbundy , thank you for your report.

This is indeed a false-positive in our analyzer. I created a ticket to keep track of this problem on our side.

Cheers,

Gyula

Thank you, Gyula! :slight_smile: