Skip to content

Add "emptycase" linter #3489

Open
Open
@leonklingele

Description

@leonklingele

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvementlinter: newSupport new linterno decisionNo decision to fix or not

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions