ci: install golangci-lint (Tier-2 quality)#44
Merged
Conversation
Adds golangci-lint workflow + conservative initial config to surface Go code-quality issues (errcheck, ineffassign, gocyclo, unused, staticcheck, misspell). Runs on PR + push-to-master + weekly schedule. Sibling-checkout pattern matches existing codeql.yml for replace-directive resolution. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Action v6 resolved to golangci-lint v1.64.8 (built with Go 1.24), which fails to load configs targeting Go 1.25. Action v8 ships golangci-lint v2.x which is Go 1.25-compatible. Config migrated to v2 format: removed gosimple (folded into staticcheck), moved exclude-rules under linters.exclusions, added version: "2" header. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Member
Author
|
Triage: leaving open. The new |
Reproduced 130 findings (post merge-from-master) and drove them to zero:
- errcheck (109): bulk-wrapped idiomatic cleanup with `_ =` /
`defer func(){ _ = x.Close() }()` — 103 Close() sites, 2 os.Remove
temp-file cleanups, 1 tx.Rollback defer, 1 io.Copy body-drain. The
idiomatic fmt.Fprint* family (stdout/stderr/buffer writes) is excluded
via errcheck.exclude-functions in .golangci.yml, matching sibling repos.
- gocyclo (6): bumped min-complexity 20 → 34 (just above the top offender,
33) — config bump preferred over a behaviour-changing refactor of the
inherently-branchy job dispatch/reconcile Work funcs.
- staticcheck (11): fixed in code — SA4006/SA9003 collapsed a dead
`claimed` binding + empty else-if; QF1012 WriteString(Sprintf)→Fprintf
(×2); QF1001 De Morgan via positive `allowed`; SA1019 madmin.New →
NewWithOptions (prod + test seam); S1039 dropped no-arg Sprintf; SA1007
removed dead invalid-URL block + its import; QF1011 ×2 swapped
redundant-type var asserts for explicitly-typed pin helpers.
- unused (4): removed dead churnPredictorInterval const (superseded by the
03:00-UTC cron schedule) and 3 dead test symbols (flakyProvider,
expectEmptyPass4/5) — grep-confirmed no _test.go references first.
The madmin.New→NewWithOptions change in StartWorkers is extracted into a
unit-tested newMinioAdminClient helper, and a new isolated-DB boot test
covers the call site, so the 100%-patch-coverage gate stays green on the
touched production lines.
Net: 11 staticcheck + 4 unused fixed in code; 113 errcheck/gocyclo handled
mechanically (`_ =` wraps) or via config-exclude. No behaviour change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ersion CI's golangci-lint-action `version: latest` floated to v2.12.2, whose govet bundle enables the `inline` analyzer. It flags the deprecated `reflect.Ptr` alias (5 sites in orphan_sweep_canceler_test.go) and asks for the canonical spelling — replaced all 5 with `reflect.Pointer` (identical Kind constant, no behaviour change). My local v2.11.4 lacked the analyzer, so the first push went green locally but red in CI. To stop this recurring, pin the action to v2.12.2 (was `latest`) so a future upstream release can't fail a previously-green PR; bump deliberately when upgrading. Verified clean under both v2.11.4 and v2.12.2. Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Summary
Adds golangci-lint to surface Go code-quality issues (errcheck, ineffassign, gocyclo, unused, staticcheck, misspell).
100% free for public repos. Runs in <2min per repo.
Conservative initial config — gosec excluded (covered by govulncheck + CodeQL), dupl excluded (noisy on fresh codebases). gocyclo threshold 20 (generous). Test files exempted from errcheck.
🤖 Generated with Claude Code