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

S1764 raises an issue when "!=" or "==" is used to check if a value is "nan".

    Details

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

      Description

      Some projects use the following pattern:

      if value != value:  # False Positive
         ...
      

      This self comparison is used sometimes to check if a value is nan. Example:

      mynan = float('nan')
      mynan != mynan  # this is True
      

      Here is a real example in Sentry

      Thus rule S1764 should not raise on expressions of the form a != a or a == a.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated: