Enable govet and additional correctness linters in golangci-lint - #1631
Open
randomizedcoder wants to merge 2 commits into
Open
Enable govet and additional correctness linters in golangci-lint#1631randomizedcoder wants to merge 2 commits into
randomizedcoder wants to merge 2 commits into
Conversation
Flagged by the linters enabled in the following commit: - main: drop a wasted new(prober.Result) allocation that is overwritten in both branches of the following if/else (wastedassign). - prober/http_test: remove unnecessary []byte(msg) conversions, msg is already a []byte (unconvert). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: randomizedcoder <dave.seddon.ca@gmail.com>
Follow-up to prometheus#1624. The config ran only misspell, revive, sloglint and staticcheck. govet was not enabled, and go test's built-in vet subset skips the composites and unreachable analyzers — which is why prometheus#1624's findings were not caught by CI (verified: reintroducing them makes this config flag both unreachable and composites). Enable govet (with the composites analyzer) plus a curated, low-noise correctness set: copyloopvar, durationcheck, ineffassign, makezero, unconvert and wastedassign. The unconvert/wastedassign findings are fixed in the preceding commit. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: randomizedcoder <dave.seddon.ca@gmail.com>
This was referenced Jul 20, 2026
SuperQ
reviewed
Jul 21, 2026
SuperQ
left a comment
Member
There was a problem hiding this comment.
I'm not a fan of enabling linters for the sake of enabling them. Especially if an LLM just does it with no thought or reasoning behind it.
Contributor
Author
Contributor
Author
|
Sorry - I want to apologize With this PR. I was hoping to help contribute, and so this PR goes to an extreme from the static analysis We definitely don't need to go this far and it's just a suggestion Happy to adjust the level up/down based on feedback |
SuperQ
pushed a commit
to prometheus/exporter-toolkit
that referenced
this pull request
Jul 23, 2026
* web: avoid aliasing cert.DNSNames when building the SAN list gocritic's appendAssign check flags append(cert.DNSNames, cert.EmailAddresses...): appending to cert.DNSNames mutates its backing array when it has spare capacity, which could surprise a caller still holding the certificate. slices.Concat always allocates a fresh slice, which is the intent here. No functional change; slices is already imported. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: randomizedcoder dave.seddon.ca@gmail.com <dave.seddon.ca@gmail.com> * lint: enable govet (all) and a set of correctness linters Mirrors prometheus/blackbox_exporter#1631. Enables copyloopvar, durationcheck, gocritic, makezero, unconvert, and wastedassign, plus govet enable-all (minus fieldalignment and shadow, which are noisy / idiomatic in this codebase). These are low-noise correctness checks; after the preceding appendAssign fix there are no findings on the tree. golangci-lint run ./... is clean, and go build / go test ./... pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: randomizedcoder dave.seddon.ca@gmail.com <dave.seddon.ca@gmail.com> --------- Signed-off-by: randomizedcoder dave.seddon.ca@gmail.com <dave.seddon.ca@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.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.
Follow-up to #1624. As noted there — "I think I will followup with some
additional linters in our golangci-lint config" — here is a proposed set.
Why
The config runs only
misspell,revive,sloglintandstaticcheck.govetis not enabled, andgo test's built-in vet subset skips thecompositesandunreachableanalyzers — which is exactly why the findingsfixed in #1624 were not caught by CI. (Verified: reintroducing those issues
makes this config flag both
unreachableandcomposites.)What
Enable
govet(with thecompositesanalyzer) plus a curated, low-noisecorrectness set:
copyloopvar,durationcheck,ineffassign,makezero,unconvert,wastedassign. Thewastedassign(main) andunconvert(http_test) findings these surface are fixed in the first commit.
go build,go test ./..., andgolangci-lint run(pinned v2.11.4) all pass.Happy to trim/extend the set to your preference. A follow-up will add
nilerr(it depends on a separate dropped-error fix, #1629).
🤖 Generated with Claude Code