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

S5795 should not raise when operands have a different types

    Details

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

      Description

      This is a minor issue as I haven't seen any occurence on Peach. Yet if it happens it will create some confusion.

      Rule RSPEC-5795 overlaps with RSPEC-3403 and RSPEC-5727 when operands of an identity operator have different types. The message of RSPEC-5795 is confusing in this case. Only RSPEC-3403 ad RSPEC-5727 should raise when the types are different.

      Example:

      if hash("a") is None:  # No issue from RSPEC-5795. Noncompliant for RSPEC-5727.
              pass
      
      if hash("a") is "test":  # No issue from RSPEC-5795. Noncompliant for RSPEC-3403.
              pass
      

        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: