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

FN on rule S5719: no issue raised on old-style classmethods

    Details

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

      Description

      Rule RSPEC-5719 doesn't raise on the following code:

      class A:
          def old_style_class_method():  # Noncompliant. False Negative
              print("old_style_class_method")
          old_style_class_method = classmethod(old_style_class_method)
      

      This is a minor issue as the modern way to define classmethods is:

      class A:
          @classmethod
          def old_style_class_method():  # Noncompliant. False Negative
              print("old_style_class_method")
      

      We already raise issue on this code pattern.

      Note that we shouldn't raise on staticmethods the same way (and we already have an exception for that):

      class A:
          def old_style_static_method():  # Compliant
              print("old_style_static_method")
          old_style_static_method = staticmethod(old_style_static_method)
      

        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: