Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "emptycase" linter #3489

Open
leonklingele opened this issue Jan 18, 2023 · 2 comments
Open

Add "emptycase" linter #3489

leonklingele opened this issue Jan 18, 2023 · 2 comments
Labels
enhancement New feature or improvement linter: new Support new linter no decision No decision to fix or not

Comments

@leonklingele
Copy link
Member

Your feature request related to a problem? Please describe.

The emptycase linter finds case statements with no body.

As per their README:


It is common knowledge for gopher that there is no fall through in the switch-case statement of the Go language. However, people who are used to C or Java may inadvertently write code like the following.

func f() {
	v := 1
	switch v {
	case 1:
	case 2:
		fmt.Println("execute")
	}
}

Of course, Println() donesn't be executed. However, it takes a while to realize this when you write it. This Analyzer detects empty cases, making it faster to notice problems.


https://github.com/gostaticanalysis/emptycase

Describe the solution you'd like.

Describe alternatives you've considered.

Additional context.

No response

@rattuscz
Copy link

Any blocker for this one?
Got burned by empty switch case and wanted to find linter for it :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement linter: new Support new linter no decision No decision to fix or not
Projects
None yet
Development

No branches or pull requests

4 participants