Skip to content

ci: Add govet shadow detection#4722

Open
johnsaigle wants to merge 5 commits intowormhole-foundation:mainfrom
johnsaigle:govet-shadow
Open

ci: Add govet shadow detection#4722
johnsaigle wants to merge 5 commits intowormhole-foundation:mainfrom
johnsaigle:govet-shadow

Conversation

@johnsaigle
Copy link
Copy Markdown
Contributor

Augment our linting set-up with shadow detection. In practice, most of our variable shadowing involves reusing err within the same scope. Even though this is pretty common in Go, we've had a few small bugs where the wrong error was logged, or where this pattern ended up returning a nil error.

To address this, shadowing is now blocked generally in the Go code.

Comment thread .golangci.yml
mdulin2
mdulin2 previously approved these changes Mar 18, 2026
@mdulin2
Copy link
Copy Markdown
Contributor

mdulin2 commented Mar 18, 2026

Good lint to add!

bemic
bemic previously approved these changes Mar 25, 2026
Copy link
Copy Markdown
Contributor

@bemic bemic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is better to read with this one. I like that

Comment thread node/cmd/guardiand/node.go Outdated
Comment thread node/cmd/guardiand/node.go
Comment thread node/pkg/txverifier/evm.go Outdated
@johnsaigle johnsaigle dismissed stale reviews from bemic and mdulin2 via 28f7285 March 27, 2026 13:29
@johnsaigle
Copy link
Copy Markdown
Contributor Author

@pleasew8t I changed some of the variable names, hopefully that's more clear. The general idea is to forbid variable shadowing in the codebase, even if current instances of shadowing are correct right now.

Copy link
Copy Markdown
Collaborator

@djb15 djb15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was concerned about the possibility of some of these semantically changing the code behaviour but I've looked at those in more detail + got claude to test some ideas for me. I think the changes are net-the-same besides the couple of deliberate fixes

Augment our linting set-up with shadow detection. In practice, most of
our variable shadowing involves reusing `err` within the same scope.
Even though this is pretty common in Go, we've had a few small bugs
where the wrong error was logged, or where this pattern ended up
returning a nil error.

To address this, shadowing is now blocked generally in the Go code.
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.

5 participants