Uploaded image for project: 'SonarSlang'
  1. SonarSlang
  2. SONARSLANG-449

[Go] - FP on S122 when a semicolon is added

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.8
    • Component/s: Go
    • Labels:
      None

      Description

      As said in Go documentation on Semicolons:

      Like C, Go's formal grammar uses semicolons to terminate statements, but unlike in C, those semicolons do not appear in the source. Instead the lexer uses a simple rule to insert semicolons automatically as it scans, so the input text is mostly free of them.

      Thus the presence of a semicolon at the end of a statement does not mean that a statement follows.

      The rule raises a False Positive when a jump statement is followed by a semicolon:

      func fn(myvar int) {
      	myvar = 42; // False Positive
      }
      

      The semicolon is superfluous but there is only one statement.

      Note that there is a similar issue for RSPEC-1763 (SONARSLANG-447)

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: