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

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

    XMLWordPrintable

    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) int {
        return myvar; // False positive
      }
      

      The semicolon is superfluous but there is no dead code.

      Note that there is a similar issue for RSPEC-122 (SONARSLANG-449)

        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: