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

False Positive on rule S905 when print statement is used with a tuple as first parameter

    Details

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

      Description

      The python parser misunderstand print statements as python 3 code when the first parameter is a tuple:

      print 1, 2  # Ok
      print (1,), 2  # False positive on "2". SonarLint parser thinks that the print statement is a python 3 call because of the parentesises.
      

      The priority is minor for the following reasons:
      Three occurences of this False Positive were visible on peach when this ticket was created. This False Positive will mostly appear on legacy code. There is an easy workaround as python 2.6 introduced from _future_ import print_function to support the print builtin function.

        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: