Uploaded image for project: 'SonarPython'
  1. SonarPython
  2. SONARPY-636

FP on rule S4487 when an attribute is referenced indirectly

    Details

    • Type: False-Positive
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.8
    • Fix Version/s: None
    • Component/s: Rules
    • Labels:
      None

      Description

      We raise when private attributes are used without referencing the class directly. To avoid this we should not raise as soon as a token in the class matches the name of the attribute, without using the symbol table.

      class Compliant:
          __indirect_access = 42
      
          def access(self):
              print(type(self).__indirect_access)
      

      Example on Peach:

      Note that there are very few such False Positives in total.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                nicolas.harraudeau Nicolas Harraudeau
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: