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

False positive U1000 when a test is skipped #968

Closed
marten-seemann opened this issue Apr 20, 2021 · 2 comments
Closed

False positive U1000 when a test is skipped #968

marten-seemann opened this issue Apr 20, 2021 · 2 comments

Comments

@marten-seemann
Copy link

func TestSkipping(t *testing.T) {
	t.Skip("skipping test")
	foo()
}

func foo() string {
	return "bar"
}

complains that foo is unused: func foo is unused (U1000)

@mvdan
Copy link
Sponsor Contributor

mvdan commented Apr 20, 2021

Maybe staticcheck considers testing.T.Skip to be a terminal statement like return or panic, and then marks the rest of the body as dead code.

That's technically true, but I think I agree with Marten - skipping a flaky test temporarily is pretty common, and one shouldn't have to delete its code or add "nolint" directives.

@dominikh
Copy link
Owner

Maybe staticcheck considers testing.T.Skip to be a terminal statement like return or panic, and then marks the rest of the body as dead code.

Correct.

or add "nolint" directives

Come again, what directives? :whelmed:

I'm aware of this problem, and it's on my todo list. I am going to close this as a duplicate of #633.

@dominikh dominikh added duplicate and removed needs-triage Newly filed issue that needs triage labels Apr 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants