chore(lint): add golangci-lint config and fix the 71 findings it surfaces - #241
Open
gregggreg wants to merge 7 commits into
Open
chore(lint): add golangci-lint config and fix the 71 findings it surfaces#241gregggreg wants to merge 7 commits into
gregggreg wants to merge 7 commits into
Conversation
Enables errorlint, nilerr, gocritic, revive, unconvert, misspell and bodyclose on top of the standard linter set. Two exclusions are recorded in-config with justification: revive's unused-parameter is skipped in test files (mock signatures require the parameters), and the stats.StatsResult stutter warning is left for a dedicated API change. Nightshift-Task: lint-fix Nightshift-Ref: https://github.com/marcus/nightshift
Replaces sentinel `!=` comparisons with errors.Is, *exec.ExitError type assertions with errors.As, and non-wrapping %v verbs with %w in fmt.Errorf. These are latent bugs: each site silently stops matching as soon as an error anywhere below it is wrapped. Nightshift-Task: lint-fix Nightshift-Ref: https://github.com/marcus/nightshift
All eight sites are deliberate graceful degradation (missing optional CLI, unreadable transcript file, best-effort quota lookup). None was a dropped error, so no control flow changed; each now carries a //nolint:nilerr directive stating why nil is the correct return. Nightshift-Task: lint-fix Nightshift-Ref: https://github.com/marcus/nightshift
Rewrites eleven if-else chains as switch statements and moves three `Deprecated:` notices into their own comment paragraph so godoc renders them as deprecation markers. In stats.go two identical branches of the projection chain collapse into a single default. Nightshift-Task: lint-fix Nightshift-Ref: https://github.com/marcus/nightshift
Renames 43 structurally-required-but-unused parameters to _ (cobra handlers, interface-mandated ctx) and renames the min/max/real locals that shadow Go builtins to minTokens/maxTokens/resolved. Two unused parameters are kept and annotated instead of renamed: Tracker.Record's tokens (deprecated published signature) and Queue.Add's t (an unimplemented stub with no call sites, so the discarded argument is scaffolding rather than a bug). Nightshift-Task: lint-fix Nightshift-Ref: https://github.com/marcus/nightshift
Adds doc comments to eight exported const blocks, fixes two malformed doc comments, justifies the blank modernc.org/sqlite import, gives cmd/provider-calibration a command comment, and demotes the per-file headers in internal/agents and internal/providers so they no longer read as duplicate package comments. Moving the `Deprecated:` markers into their own paragraph made staticcheck recognise them, surfacing two uses of the deprecated budget.Tracker in the orchestrator. Both are dead scaffolding (WithBudget has no call sites and o.budget is never read); they are annotated rather than migrated, since replacing them with budget.Manager is an API change rather than a lint fix. Nightshift-Task: lint-fix Nightshift-Ref: https://github.com/marcus/nightshift
The new .golangci.yml uses the golangci-lint v2 config schema, which golangci-lint-action@v6 (a v1 driver) cannot parse. Bump the action to v8 and pin the linter to v2.12.2. Also raise the CI Go version to 1.24 to match the go directive in go.mod. Nightshift-Task: lint-fix Nightshift-Ref: https://github.com/marcus/nightshift
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
Adds a curated
.golangci.ymland fixes the 71 issues it surfaces. The repo previously had no lint config, sogolangci-lint runused defaults only and reported 0 issues — a lint pass without a config would have delivered nothing.Linters enabled on top of the standard set (errcheck, govet, ineffassign, staticcheck, unused):
errorlint,nilerr,gocritic,revive,unconvert,misspell,bodyclose.Changes, in order of value
Correctness — 9
errorlintfindings. These are latent bugs that surface as error wrapping spreads through the codebase:err != X→errors.Isincmd/nightshift/commands/daemon.go,cmd/provider-calibration/main.go(2 sites)errors.Asfor*exec.ExitErrorininternal/agents/{claude,codex,copilot}.go%v/%s→%win threefmt.Errorfcalls ininternal/scheduler/scheduler.go8
nilerrfindings — annotated, not rewritten. Every site (internal/budget/budget.go×2,internal/integrations/{github,td}.go×4,internal/providers/claude.go×2) is deliberate graceful degradation: a missing integration or an unreadable optional file falls back to a default rather than failing the run. Changing that control flow would alter runtime behavior under the guise of a style pass, so each carries a//nolint:nilerrwith a one-line justification instead. None turned out to be a genuinely dropped error.6
gocriticfindings. Three if-else chains →switch(daemon.go×2,preview_output.go); threeDeprecated:notices moved into their own paragraph.48
revivefindings. Package/const-block doc comments, malformed comment forms, a single canonical// Package providerscomment (the per-file comments inclaude.go/codex.go/copilot.gono longer read as package comments), a justification on the blankmodernc.org/sqliteimport,min/max/realbuiltin shadows renamed to context-appropriate locals and named results, and unused parameters renamed to_.CI.
.golangci.ymluses the golangci-lint v2 config schema, whichgolangci-lint-action@v6(a v1 driver) cannot parse — the Lint job would have broken the moment this merged. Bumped to@v8pinned atv2.12.2, and raised CI's Go version from1.23to1.24to match thegodirective ingo.mod.Deliberate exclusions
internal/stats.StatsResult(revive stutter warning) is left unrenamed. It's an exported cross-package API rename and does not belong in a lint PR. Excluded in.golangci.ymlwith an in-config justification.unused-parameterin_test.gofiles. Mock implementations must match interface signatures; renaming those parameters to_costs readability for no benefit.website/(Docusaurus +node_modules) is untouched — no lint config exists there and it's outside the Go module.Verification
Run on this branch, rebased onto
main, aftergolangci-lint cache clean:The test suite was recorded as a baseline before any edit and re-run after; results are unchanged, so no "style" fix altered behavior.
Note on history
Earlier iterations of this branch were stacked on
docs-backfill. It has been rebased ontomain, so the PR now carries only the 7 lint commits with no unrelated docs churn.