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

False Negative for S905 in "except" blocks

    Details

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

      Description

      Currently the rule has an exception for try...except blocks. This exception is a bit too broad as it excludes both the body of the try and the body of the except. The rule should still raise issues in the except block.

      def tryExcept(a, b):
          """No issue is raised when the statement is THE ONLY statement in a try...except body.
          Such pattern indicates that the statement is expected to raise an exception in some contexts.
          """
          try:
              a + b
          except IndexError as e:
              a + b  # Noncompliant. False Negative
      

        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: