Skip to content

Commit

Permalink
SA9003: disable by default
Browse files Browse the repository at this point in the history
Flagging empty bodies in 'if' or 'else' blocks does sometimes find
missing code. However, it also prevents the useful idiom of documenting
why a branch isn't doing anything, as in

	if x {
		doSomething()
	} else {
		// If x isn't set, then so and so can't be the case and there's
		// nothing to do here.
	}

Over the years I've come to the conclusion that preventing these
comments is more harmful than the presence of accidentally empty
branches.

Updates: gh-321
  • Loading branch information
dominikh committed Oct 15, 2023
1 parent 7b6dc76 commit 4ffded3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions staticcheck/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1142,10 +1142,11 @@ instead.`,
},

"SA9003": {
Title: `Empty body in an if or else branch`,
Since: "2017.1",
Severity: lint.SeverityWarning,
MergeIf: lint.MergeIfAny,
Title: `Empty body in an if or else branch`,
Since: "2017.1",
NonDefault: true,
Severity: lint.SeverityWarning,
MergeIf: lint.MergeIfAny,
},

"SA9004": {
Expand Down

0 comments on commit 4ffded3

Please sign in to comment.