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.
This commit is contained in:
sam committed 2026-08-22 02:03:11 +10:00
1 parent 9dc009d267
commit a0d569da09
5 files changed
+12 -6

No files matched your search

+3 -1
View File
@@ -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)
}()
@@ -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
}
+3 -1
View File
@@ -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)
}()
+3 -1
View File
@@ -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)
+1 -1
View File
@@ -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)
}