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

[Go] - FP on S1763 when jumps are followed by labelled code

    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

      RSPEC-1763 currently says

      Jump statements (return, break, continue, goto) and throw expressions move control flow out of the current code block. So any unlabelled statements that come after a jump are dead code.

      The rule currently raises false positive when code following a jump statement is labelled.

      func fn(myvar int) int {
      	if (myvar > 10) {
      		goto Foo
      	}
      	return 42 // False positive
      Foo:
      	fmt.Println("Hello world")
      	return 21
      }
      

        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: