org.sonar.l10n.go.rules.go.S131.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sonar-go-plugin Show documentation
Show all versions of sonar-go-plugin Show documentation
SonarQube analyzer for Go language
Why is this an issue?
The requirement for a final default clause is defensive programming. The clause should either take appropriate action, or contain a
suitable comment as to why no action is taken.
Noncompliant code example
switch tag { // Noncompliant - default case is missing
case 0, 1, 2, 3:
foo()
case 4, 5, 6, 7:
bar()
}
Compliant solution
switch tag {
case 0, 1, 2, 3:
foo()
case 4, 5, 6, 7:
bar()
default:
qix()
}
Resources
© 2015 - 2025 Weber Informatics LLC | Privacy Policy