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

Fix build with golangci-lint 1.54.2 #2107

Merged
merged 2 commits into from
Sep 5, 2023
Merged

Conversation

mtrmac
Copy link
Collaborator

@mtrmac mtrmac commented Sep 5, 2023

Currently that fails with:

storage/storage_test.go:183:11: SA5011: possible nil pointer dereference (staticcheck)
		spec := ref.StringWithinTransport()
		        ^
storage/storage_test.go:188:6: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
		if ref == nil {

which is a real bug; and

storage/storage_test.go:183:11: SA5011: possible nil pointer dereference (staticcheck)
		spec := ref.StringWithinTransport()
		        ^
storage/storage_test.go:180:6: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
		if ref == nil {

which is a false positive, AFAICS.

See individual commit messages for details; one of them is just a workaround, but it seems worth doing anyway.

Found by golangci-lint / staticcheck

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
The primary reason is that golangci-lint 1.54.2 has a false
positive about a nil dereference of "ref"; somehow it can't
see the t.Fatalf() as a terminating call.

Secondarily, testify is less verbose, so hopefully
easier to follow.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
@rhatdan
Copy link
Member

rhatdan commented Sep 5, 2023

LGTM

@rhatdan rhatdan merged commit c58e7f0 into containers:main Sep 5, 2023
@mtrmac mtrmac deleted the recent-lint branch September 5, 2023 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants