Skip to content

chore(lint): tighten golangci-lint for agents, normalize mock filenames, add yq#404

Merged
schmitthub merged 4 commits into
mainfrom
chore/golangci-lint-config
Jun 24, 2026
Merged

chore(lint): tighten golangci-lint for agents, normalize mock filenames, add yq#404
schmitthub merged 4 commits into
mainfrom
chore/golangci-lint-config

Conversation

@schmitthub

Copy link
Copy Markdown
Owner

Summary

  • Tighten complexity caps for autonomous-agent workflows — agents fix lint nags for free, so the human-tuned (maratori) caps were under-tuned. cyclop max-complexity 30→15, package-average 10→8, gocognit 20→12, funlen 100/50→60/40. Scoped to changed code via existing new-from-merge-base: main, so legacy isn't carpet-bombed.
  • Normalize test-double filenames to the _mock.go / stubs.go suffix convention so the mocks/stubs lint-exclusion rules actually match them (two files previously escaped the exclusion and got full default: all linting):
    • mock_manager.gomanager_mock.go, mock_moby.gomoby_mock.go
    • fake_client.gostubs.go (×2), fake_client_test.gostubs_test.go
    • Suffix matches Go's native filename-role convention (_test.go, _GOOS.go); the mock_ prefix is a gomock package/type-ism, not a file convention.
  • Add yq v4.53.3 to the build with checksum verification (maintainer extract-checksum.shsha256sum -c; SHA-256 column self-discovered, not hardcoded).

Verification

  • go build ./... — OK
  • golangci-lint config verify — valid
  • Renamed files confirmed matched by the mocks//_mock.go/stubs.go exclusion regexes (Go RE2)
  • yq verify chain live-tested in-container (arm64) → OK
  • Full pre-commit suite green: golangci-lint-full, unit tests, govulncheck, gitleaks, semgrep

🤖 Generated with Claude Code

…es, add yq

- Tighten complexity caps for autonomous-agent workflows: cyclop
  max-complexity 30->15, package-average 10->8, gocognit 20->12,
  funlen 100/50->60/40
- Normalize prefix-style test doubles to the suffix convention so the
  mocks/stubs lint-exclusion rules match them: mock_*.go -> *_mock.go,
  fake_client.go -> stubs.go
- Add yq v4.53.3 to the build with checksum verification (extract-checksum.sh
  + sha256sum)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 24, 2026 03:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens golangci-lint thresholds for agent-driven changes, normalizes mock/stub filenames so existing lint exclusions match, and extends the build image tooling by adding yq with checksum verification.

Changes:

  • Tighten lint complexity limits (cyclop/gocognit/funlen) and restructure .golangci.yml while keeping “new-from-merge-base: main” scoping.
  • Add/rename Go test doubles (whail/moby fakes, hostproxy mock manager, docker-layer fake client + tests) to align with _mock.go / stubs.go conventions.
  • Add yq installation in .clawker.yaml with checksum verification.

Reviewed changes

Copilot reviewed 2 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/whail/whailtest/stubs.go Adds a function-field fake for moby/client.APIClient with call recording.
internal/hostproxy/hostproxytest/manager_mock.go Adds a lightweight hostproxy.Service test double.
internal/docker/mocks/stubs.go Adds a docker-layer fake client built on whailtest.FakeAPIClient.
internal/docker/mocks/stubs_test.go Adds unit tests covering the docker-layer fake client behavior.
internal/docker/mocks/moby_mock.go Adds HTTP-transport-based helpers for mocking moby client requests.
.golangci.yml Tightens lint thresholds and reworks exclusions/settings.
.clawker.yaml Installs yq into the build image with checksum validation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .clawker.yaml Outdated
schmitthub and others added 3 commits June 24, 2026 04:04
new-from-merge-base: main can't resolve the `main` ref in CI (detached
HEAD checkout, no local main branch), so golangci-lint silently fell back
to reporting every issue against main instead of just the diff. The
action's only-new-issues input fetches the real PR diff via the GitHub API
and passes --new-from-patch, overriding the config new-from-* options;
the config value stays correct for local pre-commit. Adds pull-requests
read permission required to fetch the diff.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Keep new-from-merge-base: main as the single config knob (identical
behavior for local pre-commit and CI). The CI checkout is a detached HEAD
with no local main branch, so map origin's main to a local ref after
checkout; fetch-depth: 0 already supplies the history for the merge-base.
Replaces the action-side only-new-issues override.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace the extract-checksum.sh approach with the websocat-style pattern
already used in this file: hardcode the per-arch yq release-binary SHA256
and verify via sha256sum -c. Removes build-time execution of an unpinned
network-fetched script (the only such block here) plus the checksums and
checksums_hashes_order fetches, pinning exact bytes per the CLAUDE.md
integrity-verification policy. yq's checksums asset is a multi-hash rhash
table, not sha256sum format, so direct validation needs the hardcoded
hash rather than a grep | sha256sum -c.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@schmitthub schmitthub merged commit 804979e into main Jun 24, 2026
17 checks passed
@schmitthub schmitthub deleted the chore/golangci-lint-config branch June 24, 2026 04:20
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants