Skip to content

Commit 0a36681

Browse files
authored
Add golangci-lint v1.62.2 (#1953)
1 parent 0da17f6 commit 0a36681

File tree

6 files changed

+49
-7
lines changed

6 files changed

+49
-7
lines changed

.github/workflows/push.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,14 @@ jobs:
4545
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
4646
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
4747
go install gotest.tools/gotestsum@latest
48-
go install honnef.co/go/tools/cmd/staticcheck@latest
4948
5049
- name: Pull external libraries
5150
run: |
5251
make vendor
5352
pip3 install wheel
5453
5554
- name: Run tests
56-
run: make test
55+
run: make testonly
5756

5857
- name: Publish test coverage
5958
uses: codecov/codecov-action@v4
@@ -90,6 +89,20 @@ jobs:
9089
# Exit with status code 1 if there are differences (i.e. unformatted files)
9190
git diff --exit-code
9291
92+
golangci:
93+
name: lint
94+
runs-on: ubuntu-latest
95+
steps:
96+
- uses: actions/checkout@v4
97+
- uses: actions/setup-go@v5
98+
with:
99+
go-version: 1.23.2
100+
- name: golangci-lint
101+
uses: golangci/golangci-lint-action@v6
102+
with:
103+
version: v1.62.2
104+
args: --timeout=15m
105+
93106
validate-bundle-schema:
94107
runs-on: ubuntu-latest
95108

.golangci.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
linters:
2+
disable-all: true
3+
enable:
4+
# errcheck and govet are part of default setup and should be included but give too many errors now
5+
# once errors are fixed, they should be enabled here:
6+
#- errcheck
7+
- gosimple
8+
#- govet
9+
- ineffassign
10+
- staticcheck
11+
- unused
12+
- gofmt
13+
linters-settings:
14+
gofmt:
15+
rewrite-rules:
16+
- pattern: 'a[b:len(a)]'
17+
replacement: 'a[b:]'
18+
issues:
19+
exclude-dirs-use-default: false # recommended by docs https://golangci-lint.run/usage/false-positives/

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
"editor.insertSpaces": false,
44
"editor.formatOnSave": true
55
},
6+
"go.lintTool": "golangci-lint",
7+
"go.lintFlags": [
8+
"--fast"
9+
],
610
"files.trimTrailingWhitespace": true,
711
"files.insertFinalNewline": true,
812
"files.trimFinalNewlines": true,

Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ fmt:
77
@gofmt -w $(shell find . -type f -name '*.go' -not -path "./vendor/*")
88

99
lint: vendor
10-
@echo "✓ Linting source code with https://staticcheck.io/ ..."
11-
@staticcheck ./...
10+
@echo "✓ Linting source code with https://golangci-lint.run/ ..."
11+
@golangci-lint run ./...
1212

13-
test: lint
13+
lintfix: vendor
14+
@echo "✓ Linting source code with 'golangci-lint run --fix' ..."
15+
@golangci-lint run --fix ./...
16+
17+
test: lint testonly
18+
19+
testonly:
1420
@echo "✓ Running tests ..."
1521
@gotestsum --format pkgname-and-test-fails --no-summary=skipped --raw-command go test -v -json -short -coverprofile=coverage.txt ./...
1622

bundle/deploy/terraform/import.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (m *importResource) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagn
5656
buf := bytes.NewBuffer(nil)
5757
tf.SetStdout(buf)
5858

59-
//lint:ignore SA1019 We use legacy -state flag for now to plan the import changes based on temporary state file
59+
//nolint:staticcheck // SA1019 We use legacy -state flag for now to plan the import changes based on temporary state file
6060
changed, err := tf.Plan(ctx, tfexec.State(tmpState), tfexec.Target(importAddress))
6161
if err != nil {
6262
return diag.Errorf("terraform plan: %v", err)

internal/helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func (t *cobraTestRunner) RunBackground() {
250250
// Reset context on command for the next test.
251251
// These commands are globals so we have to clean up to the best of our ability after each run.
252252
// See https://github.com/spf13/cobra/blob/a6f198b635c4b18fff81930c40d464904e55b161/command.go#L1062-L1066
253-
//lint:ignore SA1012 cobra sets the context and doesn't clear it
253+
//nolint:staticcheck // cobra sets the context and doesn't clear it
254254
cli.SetContext(nil)
255255

256256
// Make caller aware of error.

0 commit comments

Comments
 (0)