From a0d569da0983b448fd84b54b06dd1e753869a6f6 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sat, 22 Aug 2026 02:03:11 +1000 Subject: [PATCH] fix: address simple findings from a repo-wide golangci-lint sweep Six mechanical fixes from `golangci-lint run ./...` (30 findings total, 23 deliberately left -- see the next commit's message for the one that grew into something bigger, and the following note for the rest): - apply.go: %v -> %w for the wrapped yaml error, matching the identical double-%w pattern already used in decode.go/discovery.go/loader.go in the same package (errorlint). - contract_test.go: filepath.Join("provider.go") with a single argument is a no-op join; replaced with the literal (gocritic). - inprocess_test.go, yaegi_test.go: two goroutines whose whole purpose is timing (does Execute return promptly on cancellation / does Run block forever), where the call's result is irrelevant -- explicitly discarded with `_, _ =` and a comment saying why, rather than silently ignored (errcheck). - find_test.go: an unchecked os.MkdirAll now matches the file's own createTestFile helper, which already checks and t.Fatals on the same operation (errcheck). Not touched, and why: 18 cyclop/gocognit/gocyclo/funlen/nestif findings require extracting helpers to reduce complexity -- the exact shape of two regressions already recorded in CLAUDE.md's Lint-driven changes section (one from --fix silently dropping a predicate, one from a nestif extraction that doubled data), so a blind sweep across 9 unfamiliar files was declined rather than risk a third. 2 godox findings (storage.go, worktree.go) mark real missing work; deleting the comment would hide debt, not fix it. 3 recvcheck findings (Duration, TaskEnvelope, Provenance) each mix a mandatory-pointer-receiver method (UnmarshalText/UnmarshalJSON's interface contract, or genuine mutation) with correctly-value-receiver read-only methods -- forcing consistency would either break interface conformance or force pointer receivers onto call sites where the value isn't addressable. Adversarially reviewed by a fresh subagent: all six confirmed behavior-neutral or behavior-improving, all touched packages pass -race, golangci-lint confirms exactly 23 issues remain (not more, not fewer), and none are new. --- internal/agentexec/inprocess_test.go | 4 +++- internal/infrastructure/configuration/apply.go | 4 ++-- internal/skillscript/yaegi_test.go | 4 +++- internal/tools/builtin/find_test.go | 4 +++- internal/tools/provider/contract_test.go | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/internal/agentexec/inprocess_test.go b/internal/agentexec/inprocess_test.go index 87abce07c..025640f77 100644 --- a/internal/agentexec/inprocess_test.go +++ b/internal/agentexec/inprocess_test.go @@ -275,7 +275,9 @@ func main() { done := make(chan struct{}) go func() { - tool.Execute(ctx, `{"path":"blocker.go"}`) + // The result is irrelevant here -- this goroutine only exists to + // prove Execute returns promptly once ctx is cancelled. + _, _ = tool.Execute(ctx, `{"path":"blocker.go"}`) close(done) }() diff --git a/internal/infrastructure/configuration/apply.go b/internal/infrastructure/configuration/apply.go index c6f4cd250..3edd5e307 100644 --- a/internal/infrastructure/configuration/apply.go +++ b/internal/infrastructure/configuration/apply.go @@ -24,10 +24,10 @@ func ApplyOverlayValues(cfg *config.Config, overrides map[string]any) error { } data, err := yaml.Marshal(overrides) if err != nil { - return fmt.Errorf("%w: encoding config overlay: %v", ErrUnreadable, err) + return fmt.Errorf("%w: encoding config overlay: %w", ErrUnreadable, err) } if err := yaml.Unmarshal(data, cfg); err != nil { - return fmt.Errorf("%w: parsing config overlay: %v", ErrUnreadable, err) + return fmt.Errorf("%w: parsing config overlay: %w", ErrUnreadable, err) } return nil } diff --git a/internal/skillscript/yaegi_test.go b/internal/skillscript/yaegi_test.go index 4bb320ca0..cb59e8ac6 100644 --- a/internal/skillscript/yaegi_test.go +++ b/internal/skillscript/yaegi_test.go @@ -111,7 +111,9 @@ func main() { done := make(chan struct{}) go func() { - Run(path) + // The result is irrelevant -- this goroutine only exists to prove + // Run never returns from a blocking script within the timeout. + _, _ = Run(path) close(done) }() diff --git a/internal/tools/builtin/find_test.go b/internal/tools/builtin/find_test.go index 370562b30..3ca13fd2a 100644 --- a/internal/tools/builtin/find_test.go +++ b/internal/tools/builtin/find_test.go @@ -19,7 +19,9 @@ func TestFindFallback(t *testing.T) { createTestFile(t, tmp, "subdir/baz.go", "package baz") createTestFile(t, tmp, "subdir/nested/deep.txt", "deep") createTestFile(t, tmp, "vendor/mod.go", "package mod") - os.MkdirAll(filepath.Join(tmp, "hiddendir"), 0o755) + if err := os.MkdirAll(filepath.Join(tmp, "hiddendir"), 0o755); err != nil { + t.Fatal(err) + } createTestFile(t, tmp, "hiddendir/visible.txt", "text") ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) diff --git a/internal/tools/provider/contract_test.go b/internal/tools/provider/contract_test.go index dadee85f6..b5ed83556 100644 --- a/internal/tools/provider/contract_test.go +++ b/internal/tools/provider/contract_test.go @@ -10,7 +10,7 @@ import ( func TestToolProviderEngineContractExists(t *testing.T) { t.Parallel() - source, err := os.ReadFile(filepath.Join("provider.go")) + source, err := os.ReadFile("provider.go") if err != nil { t.Fatalf("read provider.go: %v", err) }