Skip to content

all: fix all golangci-lint issues and make the lint gate strict#56

Merged
rail merged 1 commit into
masterfrom
rail/golangci-lint-fixes
Jun 9, 2026
Merged

all: fix all golangci-lint issues and make the lint gate strict#56
rail merged 1 commit into
masterfrom
rail/golangci-lint-fixes

Conversation

@rail

@rail rail commented Jun 9, 2026

Copy link
Copy Markdown
Member

What

Fixes all 75 pre-existing golangci-lint findings and removes the new-from-merge-base grandfather 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

  • errcheck — handled the genuine, checkable errors in code (os.Stdout.Write and printer.Config.Fprint in main.go). The 44 renderer writes go to in-memory bytes.Buffers that cannot fail, so fmt.Fprint* and (io.Writer).Write are excluded via errcheck config rather than littering the renderers with _ =. Temp-file cleanup os.Remove calls in diff.go are explicitly ignored.
  • staticcheck — replaced deprecated io/ioutil.TempFile with os.CreateTemp (also clears the govet inline finding); strings.Replace(..,-1)strings.ReplaceAll; //nolint:staticcheck on the intentional ast.Object identity check in the vendored gofmt simplifier.
  • revive — added package + exported-symbol doc comments, ++/--, removed an empty block, renamed a rune-shadowing local.
  • unused — deleted the dead simplify func and unused reflect vars in simplify.go.
  • misspellpsuedopseudo.

Verification

  • golangci-lint run ./...0 issues (full repo, grandfather removed)
  • go build ./... && go test -race ./... → pass
  • go vet ./... clean; go mod tidy no diff
  • crlfmt self-check clean

No behavioral changes intended.

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>
@rail rail requested a review from RaduBerinde June 9, 2026 11:41

@RaduBerinde RaduBerinde left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@rail rail merged commit 82cafed into master Jun 9, 2026
4 checks passed
@rail rail deleted the rail/golangci-lint-fixes branch June 9, 2026 13:31
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