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

Rule S5603: Unused scope-limited definitions should be removed

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.1
    • Component/s: Rules
    • Labels:
      None

      Description

      Note that methods and classes can be used in another method before they are defined.
      Example:

      def compliant():
          def using():  # Ok
              nested_function()
              NestedClass()
      
          def nested_function():  # Ok
              print("nested_function")
          
          class NestedClass:  # Ok
              def __init__(self):
                  print("NestedClass")
      
          using()
      
      
      def noncompliant():
          def using():  # Noncompliant
              nested_function()
              NestedClass()
      
          def nested_function():  # Ok
              print("nested_function")
          
          class NestedClass:  # Ok
              def __init__(self):
                  print("NestedClass")
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              guillaume.dequenne Guillaume Dequenne
              Reporter:
              nicolas.harraudeau Nicolas Harraudeau (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: