Skip to content

Commit 2c001ab

Browse files
authored
chore: Upgrades golangci-lint to v2 (#1327)
1 parent 8126f13 commit 2c001ab

File tree

6 files changed

+96
-122
lines changed

6 files changed

+96
-122
lines changed

.github/workflows/code-health.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ jobs:
5050
go-version-file: 'cfn-resources/go.mod'
5151
cache: false # see https://github.com/golangci/golangci-lint-action/issues/807
5252
- name: golangci-lint
53-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84
53+
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd
5454
with:
55-
version: v1.60.3 # Also update GOLANGCI_VERSION variable in Makefile when updating this version
55+
version: v2.0.2 # Also update GOLANGCI_VERSION variable in Makefile when updating this version
5656
working-directory: cfn-resources
5757
- name: actionlint
5858
run: |

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ldXflags=github.com/mongodb/mongodbatlas-cloudformation-resources/util.defaultLo
88
ldXflagsD=github.com/mongodb/mongodbatlas-cloudformation-resources/util.defaultLogLevel=debug
99

1010
MOCKERY_VERSION=v2.42.1
11-
GOLANGCI_VERSION=v1.60.3 # Also update golangci-lint GH action in code-health.yml when updating this version
11+
GOLANGCI_VERSION=v2.0.2 # Also update golangci-lint GH action in code-health.yml when updating this version
1212

1313
.PHONY: submit
1414
submit:

cfn-resources/.golangci.yml

Lines changed: 88 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,107 @@
1-
linters-settings:
2-
exhaustive:
3-
default-signifies-exhaustive: true
4-
5-
gocritic:
6-
enabled-tags:
7-
- diagnostic
8-
- experimental
9-
- opinionated
10-
- performance
11-
- style
12-
disabled-checks:
13-
# cfn handlers generated automatically, below are exempted for the same
14-
- hugeParam
15-
- paramTypeCombine
16-
govet:
17-
enable-all: true
18-
19-
revive:
20-
# see https://github.com/mgechev/revive#available-rules for details.
21-
ignore-generated-header: true
22-
severity: warning
23-
rules:
24-
- name: blank-imports
25-
- name: context-as-argument
26-
- name: context-keys-type
27-
- name: dot-imports
28-
- name: error-return
29-
- name: error-strings
30-
- name: error-naming
31-
- name: errorf
32-
- name: exported
33-
- name: indent-error-flow
34-
- name: if-return
35-
- name: increment-decrement
36-
- name: var-naming
37-
- name: var-declaration
38-
- name: package-comments
39-
- name: range
40-
- name: receiver-naming
41-
- name: time-naming
42-
- name: unexported-return
43-
- name: indent-error-flow
44-
- name: errorf
45-
- name: empty-block
46-
- name: superfluous-else
47-
- name: struct-tag
48-
# Too many unusued parameters, skipping this check for now
49-
#- name: unused-parameter
50-
- name: unreachable-code
51-
- name: redefines-builtin-id
52-
misspell:
53-
locale: US
54-
ignore-words:
55-
- cancelled
56-
lll:
57-
# Default is 120. '\t' is counted as 1 character.
58-
# set our project to 500, as we are adding open api field description in the schema.
59-
# also, for anyone using vscode, use the following configs:
60-
# "rewrap.wrappingColumn": 500 ... requires the rewrap plugin
61-
# "editor.rulers": [500]
62-
line-length: 500
63-
nestif:
64-
# minimal complexity of if statements to report, 5 by default
65-
min-complexity: 7
66-
mnd:
67-
checks:
68-
- case
69-
- operation
70-
- return
71-
funlen:
72-
lines: 360
73-
statements: 120
1+
version: "2"
2+
run:
3+
modules-download-mode: readonly
4+
tests: true
745
linters:
75-
disable-all: true
6+
default: none
767
enable:
8+
- copyloopvar
779
- dogsled
7810
- errcheck
11+
- exhaustive
7912
- funlen
8013
- gocritic
81-
- gofmt
82-
- goimports
83-
- revive
84-
- mnd
8514
- goprintffuncname
8615
- gosec
87-
- gosimple
8816
- govet
8917
- ineffassign
9018
- lll
19+
- makezero
9120
- misspell
21+
- mnd
9222
- nakedret
23+
- noctx
9324
- nolintlint
25+
- revive
9426
- rowserrcheck
95-
- copyloopvar
9627
- staticcheck
97-
- stylecheck
98-
- typecheck
28+
- testifylint
29+
- testpackage
30+
- thelper
9931
- unconvert
10032
- unused
10133
- whitespace
102-
- thelper
103-
- testifylint
104-
- exhaustive
105-
- makezero
106-
- noctx
107-
- tenv
108-
- testpackage
109-
110-
# don't enable:
111-
# - deadcode
112-
# - varcheck
113-
# - structcheck
114-
# - depguard # Go linter that checks if package imports are in a list of acceptable packages [fast: true, auto-fix: false]
115-
# - gocyclo # we already have funlen lint
116-
# - dupl # we have a lot of duplicate test cases
117-
# - gochecknoinits # we need the init function for the provider
118-
# - gochecknoglobals # we need some global variables
119-
# - unparam # Forces to create global variables when one variable is repeated in different functions
120-
# - goerr113 # It does not allow you to return an error, you need to save the error in a variable to do it
121-
# - goconst
122-
# - gocognit
123-
issues:
124-
exclude:
125-
- declaration of ".*" shadows declaration at line .*
126-
run:
127-
timeout: 10m
128-
tests: true
129-
build-tags:
130-
- integration
131-
modules-download-mode: readonly
34+
settings:
35+
exhaustive:
36+
default-signifies-exhaustive: true
37+
funlen:
38+
lines: 360
39+
statements: 120
40+
gocritic:
41+
disabled-checks:
42+
- hugeParam
43+
- paramTypeCombine
44+
enabled-tags:
45+
- diagnostic
46+
- experimental
47+
- opinionated
48+
- performance
49+
- style
50+
govet:
51+
enable-all: true
52+
lll:
53+
line-length: 500
54+
misspell:
55+
locale: US
56+
ignore-rules:
57+
- cancelled
58+
mnd:
59+
checks:
60+
- case
61+
- operation
62+
- return
63+
nestif:
64+
min-complexity: 7
65+
revive:
66+
severity: warning
67+
rules:
68+
- name: blank-imports
69+
- name: context-as-argument
70+
- name: context-keys-type
71+
- name: dot-imports
72+
- name: error-return
73+
- name: error-strings
74+
- name: error-naming
75+
- name: errorf
76+
- name: exported
77+
- name: indent-error-flow
78+
- name: if-return
79+
- name: increment-decrement
80+
- name: var-naming
81+
- name: var-declaration
82+
- name: package-comments
83+
- name: range
84+
- name: receiver-naming
85+
- name: time-naming
86+
- name: unexported-return
87+
- name: indent-error-flow
88+
- name: errorf
89+
- name: empty-block
90+
- name: superfluous-else
91+
- name: struct-tag
92+
- name: unreachable-code
93+
- name: redefines-builtin-id
94+
exclusions:
95+
generated: lax
96+
presets:
97+
- comments
98+
- common-false-positives
99+
- legacy
100+
- std-error-handling
101+
rules:
102+
- path: (.+)\.go$
103+
text: declaration of ".*" shadows declaration at line .*
104+
formatters:
105+
enable:
106+
- gofmt
107+
- goimports

cfn-resources/cluster/cmd/resource/mappings_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func TestNewHardwareSpec(t *testing.T) {
113113
hardwareSpec := resource.NewHardwareSpec(&tc.spec)
114114
hwSpecJSON, err := json.Marshal(hardwareSpec)
115115
require.NoError(t, err)
116-
assert.Equal(t, tc.expected, string(hwSpecJSON))
116+
assert.JSONEq(t, tc.expected, string(hwSpecJSON))
117117
})
118118
}
119119
}

cfn-resources/test/e2e/cluster/cluster_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,10 @@ func checkReplicationSpecs(a *assert.Assertions, replicationSpecs []admin.Replic
225225
hwSpec := config.GetElectableSpecs()
226226
a.Equal(nodeCount, hwSpec.GetNodeCount())
227227
}
228-
if i == 0 {
228+
switch i {
229+
case 0:
229230
a.Equal(zone1, spec.GetZoneName())
230-
} else if i == 1 {
231+
case 1:
231232
a.Equal(zone2, spec.GetZoneName())
232233
}
233234
}

cfn-resources/third-party-integration/cmd/resource/resource.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,8 @@ func modelToIntegration(currentModel *Model) (out *admin.ThridPartyIntegration)
326326
}
327327

328328
func integrationToModel(currentModel Model, integration *admin.ThridPartyIntegration) Model {
329-
enabled := false
330329
// if "Enabled" is not set in the inputs we dont want to return "Enabled" in outputs
331-
if currentModel.Enabled != nil {
332-
enabled = true
333-
}
330+
enabled := currentModel.Enabled != nil
334331

335332
/*
336333
The variables from the thirdparty integration are not returned back in reposnse because most of the variables are sensitive variables.

0 commit comments

Comments
 (0)