Skip to content

Commit ea170cf

Browse files
committed
Add golangci-lint v2 config and fix all lint issues across codebase
1 parent f540e20 commit ea170cf

55 files changed

Lines changed: 1701 additions & 932 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/rules/release.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,3 @@ This release adds budget reporting commands and improves error messages across a
7070
GitHub Actions extracts the CHANGELOG entry and uses it as the release description, then builds 5 platform binaries automatically.
7171

7272
> Never push a tag without a well-written CHANGELOG entry first.
73-
ry first.
74-
try first.

.gg/commands/fix.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: fix
3+
description: Run typechecking and linting, then spawn parallel agents to fix all issues
4+
---
5+
6+
Run all linting and typechecking tools, collect errors, group them by domain, and use the subagent tool to spawn parallel sub-agents to fix them.
7+
8+
## Step 1: Run Checks
9+
10+
Run each tool and capture output:
11+
- `gofmt -l .` (format errors — files that need formatting)
12+
- `go vet ./...` (type/correctness errors)
13+
- `staticcheck ./...` (lint errors — unused code, simplifications, bugs)
14+
- `go test ./... -count=1` (test failures)
15+
16+
## Step 2: Collect and Group Errors
17+
18+
Parse the output. Group errors by domain:
19+
- **Format errors**: files listed by `gofmt -l`
20+
- **Vet errors**: issues from `go vet`
21+
- **Lint errors**: issues from `staticcheck`
22+
- **Test failures**: failing tests from `go test`
23+
24+
## Step 3: Spawn Parallel Agents
25+
26+
For each domain with issues, use the subagent tool to spawn a sub-agent to fix all errors in that domain. Include the full error output and file paths in each agent's task.
27+
28+
Auto-fix format errors directly with `gofmt -w .` instead of spawning an agent.
29+
30+
## Step 4: Verify
31+
32+
After all agents complete, re-run all checks to verify all issues are resolved.

.gg/commands/test.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: test
3+
description: Run tests, then spawn parallel agents to fix failures
4+
---
5+
6+
Run all tests for this project, collect failures, and use the subagent tool to spawn parallel sub-agents to fix them.
7+
8+
## Step 1: Run Tests
9+
10+
Run unit tests with coverage:
11+
```
12+
go test ./... -count=1 -cover
13+
```
14+
15+
For integration tests (builds and executes the binary):
16+
```
17+
go test ./internal/cli/ -count=1 -tags=integration
18+
```
19+
20+
For a specific package:
21+
```
22+
go test ./internal/inngest/ -count=1 -v
23+
```
24+
25+
For a specific test:
26+
```
27+
go test ./internal/inngest/ -count=1 -v -run TestHashSigningKey
28+
```
29+
30+
For race detection:
31+
```
32+
go test ./... -count=1 -race
33+
```
34+
35+
## Step 2: If Failures
36+
37+
For each failing test, use the subagent tool to spawn a sub-agent to fix the underlying issue (not the test). Include the test name, file path, and full error output.
38+
39+
## Step 3: Re-run
40+
41+
Re-run `go test ./... -count=1 -cover` to verify all fixes and confirm coverage hasn't regressed.

.gg/commands/update.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
name: update
3+
description: Update Go dependencies, fix deprecations and security issues
4+
---
5+
6+
## Step 1: Check for Updates
7+
8+
List all dependencies and check for available updates:
9+
10+
```
11+
go list -m -u all
12+
```
13+
14+
Review the output. Modules with `[v1.X.Y]` annotations have newer versions available.
15+
16+
## Step 2: Update Dependencies
17+
18+
Update all direct and indirect dependencies to their latest minor/patch versions:
19+
20+
```
21+
go get -u ./...
22+
go mod tidy
23+
go mod verify
24+
```
25+
26+
Then check for known vulnerabilities:
27+
28+
```
29+
go install golang.org/x/vuln/cmd/govulncheck@latest
30+
govulncheck ./...
31+
```
32+
33+
If govulncheck reports any findings, update the affected module to the fixed version it recommends and re-run until clean.
34+
35+
## Step 3: Check for Deprecations & Warnings
36+
37+
Run a full build and read ALL output carefully:
38+
39+
```
40+
go build ./...
41+
go vet ./...
42+
```
43+
44+
Look for:
45+
- Deprecated function/type usage (e.g. `io/ioutil`, `strings.Title`)
46+
- Vet warnings about incorrect format strings, unreachable code, struct tags
47+
- Build warnings about minimum Go version compatibility
48+
49+
Also run staticcheck if available:
50+
51+
```
52+
go install honnef.co/go/tools/cmd/staticcheck@latest
53+
staticcheck ./...
54+
```
55+
56+
## Step 4: Fix Issues
57+
58+
For each deprecation or warning found:
59+
1. Research the recommended replacement (e.g. `io/ioutil.ReadAll``io.ReadAll`)
60+
2. Update the code
61+
3. Re-run `go vet ./...` and `staticcheck ./...`
62+
4. Verify no warnings remain
63+
64+
For security vulnerabilities:
65+
1. Update to the patched version `govulncheck` recommends
66+
2. If no patch exists, evaluate the risk and document it
67+
3. Re-run `govulncheck ./...` until clean
68+
69+
## Step 5: Run Quality Checks
70+
71+
Run the full project quality gate:
72+
73+
```
74+
go fmt ./...
75+
go vet ./...
76+
go test -race -cover ./...
77+
```
78+
79+
If golangci-lint is available:
80+
81+
```
82+
golangci-lint run ./...
83+
```
84+
85+
Fix all errors before completing. Coverage must remain at 100% on:
86+
- `pkg/output`
87+
- `internal/inngest`
88+
- `internal/common/config`
89+
- `internal/cli/commands`
90+
91+
## Step 6: Verify Clean Build
92+
93+
Clear module cache artifacts and verify everything resolves cleanly:
94+
95+
```
96+
go clean -cache -testcache
97+
go mod download
98+
go build ./...
99+
go test -count=1 ./...
100+
```
101+
102+
Confirm zero warnings and zero errors. Run `make build` to verify the final binary compiles.

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ jobs:
1212
release:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v4
15+
- uses: actions/checkout@v6
1616
with:
1717
fetch-depth: 0
1818

1919
- uses: actions/setup-go@v5
2020
with:
21-
go-version: '1.23'
21+
go-version-file: go.mod
2222
cache: true
2323

2424
- name: Extract release notes from CHANGELOG.md

.github/workflows/test.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,37 @@
1-
name: Test
1+
name: CI
22

33
on:
44
push:
55
branches: [main]
66
pull_request:
77
branches: [main]
88

9+
permissions:
10+
contents: read
11+
912
jobs:
13+
lint:
14+
name: Lint
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-go@v5
19+
with:
20+
go-version-file: go.mod
21+
cache: true
22+
- name: golangci-lint
23+
uses: golangci/golangci-lint-action@v7
24+
with:
25+
version: v2.11.3
26+
1027
test:
28+
name: Test
1129
runs-on: ubuntu-latest
1230
steps:
1331
- uses: actions/checkout@v4
1432
- uses: actions/setup-go@v5
1533
with:
16-
go-version: '1.23'
34+
go-version-file: go.mod
1735
cache: true
1836
- name: Verify dependencies
1937
run: go mod verify
@@ -22,4 +40,4 @@ jobs:
2240
- name: Vet
2341
run: go vet ./...
2442
- name: Test
25-
run: go test -v -race ./...
43+
run: go test -v -race -coverprofile=coverage.out ./...

.golangci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
version: "2"
2+
3+
formatters:
4+
enable:
5+
- gofmt
6+
- goimports
7+
settings:
8+
goimports:
9+
local-prefixes:
10+
- github.com/Coastal-Programs/inggest-cli
11+
12+
linters:
13+
default: standard
14+
enable:
15+
- bodyclose
16+
- errcheck
17+
- errorlint
18+
- gosec
19+
- govet
20+
- gocritic
21+
- goconst
22+
- gocyclo
23+
- ineffassign
24+
- misspell
25+
- nakedret
26+
- nilerr
27+
- prealloc
28+
- unconvert
29+
- unparam
30+
- unused
31+
- modernize
32+
- intrange
33+
settings:
34+
gocyclo:
35+
min-complexity: 15
36+
goconst:
37+
min-len: 3
38+
min-occurrences: 3
39+
exclusions:
40+
presets:
41+
- comments
42+
- std-error-handling
43+
- common-false-positives
44+
rules:
45+
- linters: [errcheck, gosec, gocritic, gocyclo]
46+
path: _test\.go

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Built for AI agents, shell scripts, and CI/CD pipelines.
66
- **Module:** `github.com/Coastal-Programs/inggest-cli`
77
- **Binary:** `inngest`
88
- **Config:** `~/.config/inngest/cli.json`
9-
- **Only external dep:** `github.com/spf13/cobra v1.8.1` — prefer stdlib for everything else
9+
- **External deps:** `github.com/spf13/cobra v1.10.2`, `golang.org/x/term` — prefer stdlib for everything else
1010

1111
## Commands
1212

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ help:
1616
## build: Build binary to ./build/inngest
1717
build:
1818
@mkdir -p $(BUILD_DIR)
19-
go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY) $(CMD)
19+
go build -trimpath $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY) $(CMD)
2020

2121
## install: Install binary to GOPATH/bin
2222
install:
@@ -49,7 +49,7 @@ vet:
4949

5050
## lint: Run golangci-lint (installs if missing)
5151
lint:
52-
@which golangci-lint > /dev/null 2>&1 || go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
52+
@which golangci-lint > /dev/null 2>&1 || go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.3
5353
golangci-lint run ./...
5454

5555
## check: Run fmt, vet, and lint (pre-commit gate)

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
module github.com/Coastal-Programs/inggest-cli
22

3-
go 1.25.0
3+
go 1.26.1
44

55
require (
6-
github.com/spf13/cobra v1.8.1
6+
github.com/spf13/cobra v1.10.2
77
golang.org/x/term v0.41.0
88
)
99

1010
require (
1111
github.com/inconshreveable/mousetrap v1.1.0 // indirect
12-
github.com/spf13/pflag v1.0.5 // indirect
12+
github.com/spf13/pflag v1.0.10 // indirect
1313
golang.org/x/sys v0.42.0 // indirect
1414
)

0 commit comments

Comments
 (0)