Skip to content

Commit afae549

Browse files
authored
Migrate to golangci v2[v8] (#3588)
1 parent f4391da commit afae549

23 files changed

+205
-132
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: golangci-lint
33
on:
44
push:
55
tags:
6-
- "v9.*"
76
- "v8.*"
87
pull_request:
98
types:
@@ -12,7 +11,6 @@ on:
1211
- synchronize
1312
branches:
1413
- main
15-
- v9
1614
- v8
1715
paths-ignore:
1816
- "doc/**"
@@ -36,8 +34,8 @@ jobs:
3634
- name: golangci-lint
3735
uses: golangci/golangci-lint-action@v8
3836
with:
39-
version: v1.64
40-
args: -v --exclude-dirs cf --exclude-dirs fixtures --exclude-dirs plugin --exclude-dirs command/plugin
37+
version: v2.4
38+
args: -v
4139
format:
4240
name: Run go fmt
4341
runs-on: ubuntu-latest

.golangci.json

Lines changed: 123 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,131 @@
11
{
2-
"run": {
3-
"concurrency": 4,
4-
"timeout": "20m"
2+
"formatters": {
3+
"enable": [
4+
"goimports"
5+
],
6+
"exclusions": {
7+
"generated": "lax",
8+
"paths": [
9+
"integration/helpers/fake_server.go",
10+
"command/plugin/*.go$",
11+
"third_party$",
12+
"builtin$",
13+
"examples$",
14+
"cf$",
15+
"fixtures$",
16+
"plugin$"
17+
]
18+
}
19+
},
20+
"issues": {
21+
"max-same-issues": 0
522
},
623
"linters": {
7-
"disable-all": true,
24+
"default": "none",
825
"enable": [
9-
"govet",
10-
"goimports",
1126
"errcheck",
27+
"govet",
28+
"ineffassign",
1229
"staticcheck",
13-
"unused",
14-
"ineffassign"
15-
]
16-
},
17-
"linters-settings": {},
18-
"issues": {
19-
"max-same-issues": 0,
20-
"exclude-files": [
21-
"integration/helpers/fake_server.go",
22-
"command/plugin/*.go$"
30+
"unused"
2331
],
24-
"exclude": [
25-
"Error return value of `client.GetApplicationTasks` is not checked",
26-
"Error return value of `logger.output.Stop` is not checked",
27-
"Error return value of `request.ResetBody` is not checked",
28-
"Error return value of `GinkgoWriter.Write` is not checked",
29-
"Error return value of `c.terminalHelper.RestoreTerminal` is not checked",
30-
"U1000: field `allproxy` is unused",
31-
"U1000: field `dockerPassword` is unused",
32-
"U1000: field `envCFStagingTimeout` is unused",
33-
"U1000: field `envCFStartupTimeout` is unused",
34-
"U1000: field `relatedCommands` is unused",
35-
"U1000: field `usage` is unused",
36-
"SA5008: duplicate struct tag \"choice\"",
37-
"`allproxy` is unused",
38-
"`dockerPassword` is unused",
39-
"`envCFStagingTimeout` is unused",
40-
"`envCFStartupTimeout` is unused",
41-
"`relatedCommands` is unused",
42-
"`usage` is unused"
43-
]
44-
}
32+
"settings": {
33+
"staticcheck": {
34+
"checks": [
35+
"all",
36+
"-S1002",
37+
"-S1005",
38+
"-S1007",
39+
"-S1009",
40+
"-S1011",
41+
"-S1012",
42+
"-S1016",
43+
"-S1020",
44+
"-S1039",
45+
"-ST1001",
46+
"-ST1003",
47+
"-ST1005",
48+
"-ST1012",
49+
"-ST1016",
50+
"-QF1001",
51+
"-QF1002",
52+
"-QF1003",
53+
"-QF1004",
54+
"-QF1008",
55+
"-QF1012",
56+
"-SA5008"
57+
]
58+
}
59+
},
60+
"exclusions": {
61+
"generated": "lax",
62+
"paths": [
63+
"integration/helpers/fake_server.go",
64+
"command/plugin/*.go$",
65+
"third_party$",
66+
"builtin$",
67+
"examples$",
68+
"cf$",
69+
"fixtures$",
70+
"plugin$"
71+
],
72+
"presets": [
73+
"comments",
74+
"common-false-positives",
75+
"legacy",
76+
"std-error-handling"
77+
],
78+
"rules": [
79+
{
80+
"linters": ["unused"],
81+
"text": "field usage is unused"
82+
},
83+
{
84+
"linters": ["unused"],
85+
"text": "field relatedCommands is unused"
86+
},
87+
{
88+
"linters": ["unused"],
89+
"text": "field allproxy is unused"
90+
},
91+
{
92+
"linters": ["unused"],
93+
"text": "field dockerPassword is unused"
94+
},
95+
{
96+
"linters": ["unused"],
97+
"text": "field envCFStagingTimeout is unused"
98+
},
99+
{
100+
"linters": ["unused"],
101+
"text": "field envCFStartupTimeout is unused"
102+
},
103+
{
104+
"linters": ["errcheck"],
105+
"text": "Error return value of `GinkgoWriter.Write` is not checked"
106+
},
107+
{
108+
"linters": ["errcheck"],
109+
"text": "Error return value of `client.GetApplicationTasks` is not checked"
110+
},
111+
{
112+
"linters": ["errcheck"],
113+
"text": "Error return value of `logger.output.Stop` is not checked"
114+
},
115+
{
116+
"linters": ["errcheck"],
117+
"text": "Error return value of `request.ResetBody` is not checked"
118+
},
119+
{
120+
"linters": ["errcheck"],
121+
"text": "Error return value of `c.terminalHelper.RestoreTerminal` is not checked"
122+
}
123+
]
124+
}
125+
},
126+
"run": {
127+
"concurrency": 4,
128+
"timeout": "60m"
129+
},
130+
"version": "2"
45131
}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ integration-tests-full-ci: install-test-deps integration-cleanup
145145

146146
lint: format ## Runs all linters and formatters
147147
@echo "Running linters..."
148-
golangci-lint run --exclude-dirs cf --exclude-dirs fixtures --exclude-dirs plugin --exclude-dirs command/plugin
148+
golangci-lint run -v
149149
@echo "No lint errors!"
150150

151151
# TODO: version specific tagging for all these builds

actor/v7action/deployment_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"errors"
55

66
"code.cloudfoundry.org/cli/actor/actionerror"
7-
"code.cloudfoundry.org/cli/actor/v7action"
87
. "code.cloudfoundry.org/cli/actor/v7action"
98
"code.cloudfoundry.org/cli/actor/v7action/v7actionfakes"
109
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3"
@@ -18,7 +17,7 @@ var _ = Describe("Deployment Actions", func() {
1817
var (
1918
actor *Actor
2019
executeErr error
21-
warnings v7action.Warnings
20+
warnings Warnings
2221
returnedDeploymentGUID string
2322
fakeCloudControllerClient *v7actionfakes.FakeCloudControllerClient
2423
)

actor/v7action/organization_quota_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ var _ = Describe("Organization Quota Actions", func() {
1717
var (
1818
actor *Actor
1919
fakeCloudControllerClient *v7actionfakes.FakeCloudControllerClient
20-
trueValue bool = true
21-
falseValue bool = false
20+
trueValue = true
21+
falseValue = false
2222
)
2323

2424
BeforeEach(func() {

actor/v7action/revisions_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"strconv"
66

77
"code.cloudfoundry.org/cli/actor/actionerror"
8-
"code.cloudfoundry.org/cli/actor/v7action"
98
. "code.cloudfoundry.org/cli/actor/v7action"
109
"code.cloudfoundry.org/cli/actor/v7action/v7actionfakes"
1110
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3"
@@ -403,7 +402,7 @@ var _ = Describe("Revisions Actions", func() {
403402
Describe("GetEnvironmentVariableGroupByRevision", func() {
404403
var (
405404
actor *Actor
406-
environmentVariablesGroup v7action.EnvironmentVariableGroup
405+
environmentVariablesGroup EnvironmentVariableGroup
407406
executeErr error
408407
fakeCloudControllerClient *v7actionfakes.FakeCloudControllerClient
409408
fakeConfig *v7actionfakes.FakeConfig

api/cloudcontroller/ccv3/buildpack_test.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717

1818
"code.cloudfoundry.org/cli/api/cloudcontroller/ccerror"
1919
. "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3"
20-
. "code.cloudfoundry.org/cli/resources"
2120
. "github.com/onsi/ginkgo/v2"
2221
. "github.com/onsi/gomega"
2322
. "github.com/onsi/gomega/ghttp"
@@ -121,35 +120,35 @@ var _ = Describe("Buildpacks", func() {
121120
Expect(executeErr).NotTo(HaveOccurred())
122121

123122
Expect(buildpacks).To(ConsistOf(
124-
Buildpack{
123+
resources.Buildpack{
125124
Name: "ruby_buildpack",
126125
GUID: "guid1",
127126
Position: types.NullInt{Value: 1, IsSet: true},
128127
Enabled: types.NullBool{Value: true, IsSet: true},
129128
Locked: types.NullBool{Value: false, IsSet: true},
130129
Stack: "windows64",
131130
State: "AWAITING_UPLOAD",
132-
Metadata: &Metadata{Labels: map[string]types.NullString{}},
131+
Metadata: &resources.Metadata{Labels: map[string]types.NullString{}},
133132
},
134-
Buildpack{
133+
resources.Buildpack{
135134
Name: "staticfile_buildpack",
136135
GUID: "guid2",
137136
Position: types.NullInt{Value: 2, IsSet: true},
138137
Enabled: types.NullBool{Value: false, IsSet: true},
139138
Locked: types.NullBool{Value: true, IsSet: true},
140139
Stack: "cflinuxfs4",
141140
State: "AWAITING_UPLOAD",
142-
Metadata: &Metadata{Labels: map[string]types.NullString{}},
141+
Metadata: &resources.Metadata{Labels: map[string]types.NullString{}},
143142
},
144-
Buildpack{
143+
resources.Buildpack{
145144
Name: "go_buildpack",
146145
GUID: "guid3",
147146
Position: types.NullInt{Value: 3, IsSet: true},
148147
Enabled: types.NullBool{Value: true, IsSet: true},
149148
Locked: types.NullBool{Value: false, IsSet: true},
150149
Stack: "cflinuxfs4",
151150
State: "AWAITING_UPLOAD",
152-
Metadata: &Metadata{Labels: map[string]types.NullString{}},
151+
Metadata: &resources.Metadata{Labels: map[string]types.NullString{}},
153152
},
154153
))
155154
Expect(warnings).To(ConsistOf("this is a warning", "this is another warning"))
@@ -203,9 +202,9 @@ var _ = Describe("Buildpacks", func() {
203202

204203
Describe("CreateBuildpack", func() {
205204
var (
206-
inputBuildpack Buildpack
205+
inputBuildpack resources.Buildpack
207206

208-
bp Buildpack
207+
bp resources.Buildpack
209208
warnings Warnings
210209
executeErr error
211210
)
@@ -216,7 +215,7 @@ var _ = Describe("Buildpacks", func() {
216215

217216
When("the buildpack is successfully created", func() {
218217
BeforeEach(func() {
219-
inputBuildpack = Buildpack{
218+
inputBuildpack = resources.Buildpack{
220219
Name: "some-buildpack",
221220
Stack: "some-stack",
222221
}
@@ -259,7 +258,7 @@ var _ = Describe("Buildpacks", func() {
259258
Expect(executeErr).NotTo(HaveOccurred())
260259
Expect(warnings).To(ConsistOf("this is a warning"))
261260

262-
expectedBuildpack := Buildpack{
261+
expectedBuildpack := resources.Buildpack{
263262
GUID: "some-bp-guid",
264263
Name: "some-buildpack",
265264
Stack: "some-stack",

api/cloudcontroller/ccv3/droplet_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
"code.cloudfoundry.org/cli/api/cloudcontroller"
1111
"code.cloudfoundry.org/cli/api/cloudcontroller/ccerror"
12-
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3"
12+
1313
. "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3"
1414
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes"
1515
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant"
@@ -433,7 +433,7 @@ var _ = Describe("Droplet", func() {
433433
})
434434

435435
BeforeEach(func() {
436-
requester.MakeRequestReceiveRawCalls(func(string, internal.Params, string) ([]byte, ccv3.Warnings, error) {
436+
requester.MakeRequestReceiveRawCalls(func(string, internal.Params, string) ([]byte, Warnings, error) {
437437
return []byte{'d', 'r', 'o', 'p'}, Warnings{"some-warning"}, errors.New("some-error")
438438
})
439439
})

0 commit comments

Comments
 (0)