all: fix all golangci-lint issues and make the lint gate strict#56
Merged
Conversation
CI introduced golangci-lint with new-from-merge-base so it only gated new code, grandfathering 75 pre-existing findings. Fix all of them and remove the grandfather setting so the whole repo is linted going forward. - errcheck: handle the genuine errors (os.Stdout.Write, printer.Fprint in main.go); the renderers write to in-memory bytes.Buffers that cannot fail, so exclude fmt.Fprint* and (io.Writer).Write via errcheck config. - staticcheck: replace deprecated io/ioutil with os.CreateTemp; use strings.ReplaceAll; nolint the intentional ast.Object use in the vendored gofmt simplifier. - revive: add package and exported-symbol doc comments, use ++/--, drop an empty block, rename a builtin-shadowing variable. - unused: delete the dead simplify func and unused reflect vars. - misspell: psuedo -> pseudo. Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes all 75 pre-existing golangci-lint findings and removes the
new-from-merge-basegrandfather setting so the linter now runs over the entire codebase on every PR (not just changed lines).Issue breakdown that was grandfathered: errcheck 48, revive 16, unused 4, staticcheck 3, misspell 3, govet 1.
How
os.Stdout.Writeandprinter.Config.Fprintinmain.go). The 44 renderer writes go to in-memorybytes.Buffers that cannot fail, sofmt.Fprint*and(io.Writer).Writeare excluded via errcheck config rather than littering the renderers with_ =. Temp-file cleanupos.Removecalls indiff.goare explicitly ignored.io/ioutil.TempFilewithos.CreateTemp(also clears the govetinlinefinding);strings.Replace(..,-1)→strings.ReplaceAll;//nolint:staticcheckon the intentionalast.Objectidentity check in the vendored gofmt simplifier.++/--, removed an empty block, renamed arune-shadowing local.simplifyfunc and unused reflect vars insimplify.go.psuedo→pseudo.Verification
golangci-lint run ./...→ 0 issues (full repo, grandfather removed)go build ./... && go test -race ./...→ passgo vet ./...clean;go mod tidyno diffNo behavioral changes intended.