Skip to content

Commit 5de4353

Browse files
ndeloofglours
authored andcommitted
bump golangci-lint to latest and configure CLAUDE to use it on change
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
1 parent 27d9d50 commit 5de4353

4 files changed

Lines changed: 32 additions & 5 deletions

File tree

CLAUDE.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Project: Docker Compose
2+
3+
## Build & Test
4+
5+
- Build: `make build`
6+
- Test all: `make test`
7+
- Test unit: `go test ./pkg/...`
8+
- Test single: `go test ./pkg/compose/ -run TestFunctionName`
9+
- E2E tests: `go test -tags e2e ./pkg/e2e/ -run TestName`
10+
11+
## Lint
12+
13+
- Linter: golangci-lint v2 (config in `.golangci.yml`)
14+
- Run: `golangci-lint run --build-tags "e2e" ./...`
15+
- **After modifying any Go code, ALWAYS run the linter and fix all reported issues before considering the task complete.**
16+
- Lint is also run via Docker: `docker buildx bake lint` (uses version pinned in `Dockerfile`)
17+
18+
## Code Style
19+
20+
- Formatting is enforced by golangci-lint (gofumpt + gci)
21+
- Import order: stdlib, third-party, local module (enforced by gci)
22+
- Max line length: 200 chars
23+
- Max cyclomatic complexity: 16
24+
- No `io/ioutil`, `github.com/pkg/errors`, `gopkg.in/yaml.v2`, `golang.org/x/exp/maps`, `golang.org/x/exp/slices`
25+
- Use `github.com/containerd/errdefs` instead of `github.com/docker/docker/errdefs`
26+
- In tests: use `t.Context()` instead of `context.Background()` or `context.TODO()`
27+
- Prefer `fmt.Fprintf` over `WriteString(fmt.Sprintf(...))`

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
ARG GO_VERSION=1.25.8
1919
ARG XX_VERSION=1.9.0
20-
ARG GOLANGCI_LINT_VERSION=v2.8.0
20+
ARG GOLANGCI_LINT_VERSION=v2.11.3
2121
ARG ADDLICENSE_VERSION=v1.0.0
2222

2323
ARG BUILD_TAGS="e2e"

pkg/compose/publish.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ func (s *composeService) preChecks(project *types.Project, options api.PublishOp
332332
for _, val := range detectedSecrets {
333333
b.WriteString(val.Type)
334334
b.WriteRune('\n')
335-
b.WriteString(fmt.Sprintf("%q: %s\n", val.Key, val.Value))
335+
fmt.Fprintf(&b, "%q: %s\n", val.Key, val.Value)
336336
}
337337
b.WriteString("Are you ok to publish these sensitive data?")
338338
confirm, err := s.prompt(b.String(), false)
@@ -362,7 +362,7 @@ func (s *composeService) checkEnvironmentVariables(project *types.Project, optio
362362
var errorMsg strings.Builder
363363
for _, errors := range errorList {
364364
for _, err := range errors {
365-
errorMsg.WriteString(fmt.Sprintf("%s\n", err))
365+
fmt.Fprintf(&errorMsg, "%s\n", err)
366366
}
367367
}
368368
return fmt.Errorf("%s%s", errorMsg.String(), errorMsgSuffix)
@@ -396,7 +396,7 @@ func (s *composeService) checkOnlyBuildSection(project *types.Project) (bool, er
396396
var errMsg strings.Builder
397397
errMsg.WriteString("your Compose stack cannot be published as it only contains a build section for service(s):\n")
398398
for _, serviceInError := range errorList {
399-
errMsg.WriteString(fmt.Sprintf("- %q\n", serviceInError))
399+
fmt.Fprintf(&errMsg, "- %q\n", serviceInError)
400400
}
401401
return false, errors.New(errMsg.String())
402402
}

pkg/e2e/compose_run_build_once_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@ func countServiceBuilds(output, projectName, serviceName string) int {
9595
// Format: prefix-<8 random hex chars> (e.g., "build-once-3f4a9b2c")
9696
func randomProjectName(prefix string) string {
9797
b := make([]byte, 4) // 4 bytes = 8 hex chars
98-
rand.Read(b) //nolint:errcheck
98+
rand.Read(b)
9999
return fmt.Sprintf("%s-%s", prefix, hex.EncodeToString(b))
100100
}

0 commit comments

Comments
 (0)