Skip to content

Commit 4292eec

Browse files
committed
refactor: Upgrade golangci-lint to v2.4.0
Signed-off-by: Maximilian Blatt <maximilian.blatt@accenture.com>
1 parent 9899ddf commit 4292eec

4 files changed

Lines changed: 133 additions & 215 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ on:
1010

1111
env:
1212
# Common versions
13-
GO_VERSION: '1.24.3'
14-
GOLANGCI_VERSION: 'v1.64.8'
13+
GO_VERSION: '1.25.1'
14+
GOLANGCI_VERSION: 'v2.4.0'
1515
DOCKER_BUILDX_VERSION: 'v0.14.1'
1616

1717
# Common users. We can't run a step 'if secrets.AWS_USR != ""' but we can run
@@ -118,7 +118,7 @@ jobs:
118118
# this action because it leaves 'annotations' (i.e. it comments on PRs to
119119
# point out linter violations).
120120
- name: Lint
121-
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3
121+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
122122
with:
123123
version: ${{ env.GOLANGCI_VERSION }}
124124
skip-cache: true # We do our own caching.
@@ -313,7 +313,7 @@ jobs:
313313
with:
314314
username: ${{ secrets.CONTRIB_DOCKER_USR }}
315315
password: ${{ secrets.CONTRIB_DOCKER_PSW }}
316-
316+
317317
- name: Login to GHCR
318318
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
319319
with:

.golangci.yml

Lines changed: 127 additions & 209 deletions
Original file line numberDiff line numberDiff line change
@@ -1,217 +1,135 @@
1-
run:
2-
timeout: 30m
3-
4-
skip-files:
5-
- "zz_generated\\..+\\.go$"
6-
7-
output:
8-
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
9-
format: colored-line-number
10-
11-
linters-settings:
12-
errcheck:
13-
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
14-
# default is false: such cases aren't reported by default.
15-
check-type-assertions: false
16-
17-
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
18-
# default is false: such cases aren't reported by default.
19-
check-blank: false
20-
21-
# [deprecated] comma-separated list of pairs of the form pkg:regex
22-
# the regex is used to ignore names within pkg. (default "fmt:.*").
23-
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
24-
ignore: fmt:.*,io/ioutil:^Read.*
25-
26-
govet:
27-
# report about shadowed variables
28-
check-shadowing: false
29-
30-
gofmt:
31-
# simplify code: gofmt with `-s` option, true by default
32-
simplify: true
33-
34-
gci:
35-
custom-order: true
36-
sections:
37-
- standard
38-
- default
39-
- prefix(github.com/crossplane-contrib/provider-argocd)
40-
41-
gocyclo:
42-
# minimal code complexity to report, 30 by default (but we recommend 10-20)
43-
min-complexity: 10
44-
45-
maligned:
46-
# print struct with more effective memory layout or not, false by default
47-
suggest-new: true
48-
49-
dupl:
50-
# tokens count to trigger issue, 150 by default
51-
threshold: 100
52-
53-
goconst:
54-
# minimal length of string constant, 3 by default
55-
min-len: 3
56-
# minimal occurrences count to trigger, 3 by default
57-
min-occurrences: 5
58-
59-
lll:
60-
# tab width in spaces. Default to 1.
61-
tab-width: 1
62-
63-
unused:
64-
# treat code as a program (not a library) and report unused exported identifiers; default is false.
65-
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
66-
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
67-
# with golangci-lint call it on a directory with the changed file.
68-
check-exported: false
69-
70-
unparam:
71-
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
72-
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
73-
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
74-
# with golangci-lint call it on a directory with the changed file.
75-
check-exported: false
76-
77-
nakedret:
78-
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
79-
max-func-lines: 30
80-
81-
prealloc:
82-
# XXX: we don't recommend using this linter before doing performance profiling.
83-
# For most programs usage of prealloc will be a premature optimization.
84-
85-
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
86-
# True by default.
87-
simple: true
88-
range-loops: true # Report preallocation suggestions on range loops, true by default
89-
for-loops: false # Report preallocation suggestions on for loops, false by default
90-
91-
gocritic:
92-
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint` run to see all tags and checks.
93-
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
94-
enabled-tags:
95-
- performance
96-
97-
settings: # settings passed to gocritic
98-
captLocal: # must be valid enabled check name
99-
paramsOnly: true
100-
rangeValCopy:
101-
sizeThreshold: 32
102-
103-
nolintlint:
104-
require-explanation: false
105-
require-specific: true
106-
107-
revive:
108-
rules:
109-
- name: package-comments
110-
disabled: true
111-
112-
1+
version: "2"
1132
linters:
1143
enable:
115-
- megacheck
116-
- govet
117-
- gocyclo
118-
- gocritic
4+
- asasalint
5+
- asciicheck
6+
- bidichk
7+
- bodyclose
8+
- contextcheck
9+
- durationcheck
10+
- errchkjson
11+
- errorlint
12+
- exhaustive
13+
- gocheckcompilerdirectives
14+
- gochecksumtype
11915
- goconst
120-
- gci
121-
- gofmt # We enable this as well as goimports for its simplify mode.
122-
- prealloc
123-
- revive
124-
- unconvert
16+
- gocritic
17+
- gocyclo
18+
- gosec
19+
- gosmopolitan
20+
- loggercheck
21+
- makezero
12522
- misspell
23+
- musttag
12624
- nakedret
25+
- nilerr
26+
- nilnesserr
27+
- noctx
12728
- nolintlint
128-
129-
disable:
130-
# These linters are all deprecated as of golangci-lint v1.49.0. We disable
131-
# them explicitly to avoid the linter logging deprecation warnings.
132-
- deadcode
133-
- varcheck
134-
- scopelint
135-
- structcheck
136-
- interfacer
137-
138-
presets:
139-
- bugs
140-
- unused
141-
fast: false
142-
143-
29+
- prealloc
30+
- protogetter
31+
- reassign
32+
- recvcheck
33+
- revive
34+
- rowserrcheck
35+
- spancheck
36+
- sqlclosecheck
37+
- testifylint
38+
- unconvert
39+
- unparam
40+
- zerologlint
41+
settings:
42+
dupl:
43+
threshold: 100
44+
errcheck:
45+
check-type-assertions: false
46+
check-blank: false
47+
goconst:
48+
min-len: 3
49+
min-occurrences: 5
50+
gocritic:
51+
enabled-tags:
52+
- performance
53+
settings:
54+
captLocal:
55+
paramsOnly: true
56+
rangeValCopy:
57+
sizeThreshold: 32
58+
gocyclo:
59+
min-complexity: 10
60+
lll:
61+
tab-width: 1
62+
nakedret:
63+
max-func-lines: 30
64+
nolintlint:
65+
require-explanation: false
66+
require-specific: true
67+
prealloc:
68+
simple: true
69+
range-loops: true
70+
for-loops: false
71+
revive:
72+
rules:
73+
- name: package-comments
74+
disabled: true
75+
staticcheck:
76+
checks:
77+
- -QF1008
78+
unparam:
79+
check-exported: false
80+
exclusions:
81+
generated: lax
82+
rules:
83+
- linters:
84+
- dupl
85+
- errcheck
86+
- gocyclo
87+
- gosec
88+
- scopelint
89+
- unparam
90+
path: _test(ing)?\.go
91+
- linters:
92+
- gocritic
93+
path: _test\.go
94+
text: (unnamedResult|exitAfterDefer)
95+
- linters:
96+
- gocritic
97+
text: '(hugeParam|rangeValCopy):'
98+
- linters:
99+
- staticcheck
100+
text: 'SA3000:'
101+
- linters:
102+
- gosec
103+
text: 'G101:'
104+
- linters:
105+
- gosec
106+
text: 'G104:'
107+
- linters:
108+
- musttag
109+
path: k8s.io/
110+
paths:
111+
- third_party$
112+
- builtin$
113+
- examples$
144114
issues:
145-
# Excluding configuration per-path and per-linter
146-
exclude-rules:
147-
# Exclude some linters from running on tests files.
148-
- path: _test(ing)?\.go
149-
linters:
150-
- gocyclo
151-
- errcheck
152-
- dupl
153-
- gosec
154-
- scopelint
155-
- unparam
156-
157-
# Ease some gocritic warnings on test files.
158-
- path: _test\.go
159-
text: "(unnamedResult|exitAfterDefer)"
160-
linters:
161-
- gocritic
162-
163-
# These are performance optimisations rather than style issues per se.
164-
# They warn when function arguments or range values copy a lot of memory
165-
# rather than using a pointer.
166-
- text: "(hugeParam|rangeValCopy):"
167-
linters:
168-
- gocritic
169-
170-
# This "TestMain should call os.Exit to set exit code" warning is not clever
171-
# enough to notice that we call a helper method that calls os.Exit.
172-
- text: "SA3000:"
173-
linters:
174-
- staticcheck
175-
176-
- text: "k8s.io/api/core/v1"
177-
linters:
178-
- goimports
179-
180-
# This is a "potential hardcoded credentials" warning. It's triggered by
181-
# any variable with 'secret' in the same, and thus hits a lot of false
182-
# positives in Kubernetes land where a Secret is an object type.
183-
- text: "G101:"
184-
linters:
185-
- gosec
186-
- gas
187-
188-
# This is an 'errors unhandled' warning that duplicates errcheck.
189-
- text: "G104:"
190-
linters:
191-
- gosec
192-
- gas
193-
194-
# Some k8s dependencies do not have JSON tags on all fields in structs.
195-
- path: k8s.io/
196-
linters:
197-
- musttag
198-
199-
# Independently from option `exclude` we use default exclude patterns,
200-
# it can be disabled by this option. To list all
201-
# excluded by default patterns execute `golangci-lint run --help`.
202-
# Default value for this option is true.
203-
exclude-use-default: false
204-
205-
# Show only new issues: if there are unstaged changes or untracked files,
206-
# only those changes are analyzed, else only changes in HEAD~ are analyzed.
207-
# It's a super-useful option for integration of golangci-lint into existing
208-
# large codebase. It's not practical to fix all existing issues at the moment
209-
# of integration: much better don't allow issues in new code.
210-
# Default is false.
211-
new: false
212-
213-
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
214-
max-per-linter: 0
215-
216-
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
217115
max-same-issues: 0
116+
new: false
117+
formatters:
118+
enable:
119+
- gci
120+
- gofmt
121+
settings:
122+
gci:
123+
sections:
124+
- standard
125+
- default
126+
- prefix(github.com/crossplane-contrib/provider-argocd)
127+
custom-order: true
128+
gofmt:
129+
simplify: true
130+
exclusions:
131+
generated: lax
132+
paths:
133+
- third_party$
134+
- builtin$
135+
- examples$

pkg/clients/argocd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func UseProviderConfig(ctx context.Context, c client.Client, mg resource.LegacyM
9191
}
9292

9393
func authFromCredentials(ctx context.Context, c client.Client, creds v1alpha1.ProviderCredentials) (string, error) { //nolint:gocyclo
94-
switch s := creds.Source; s { //nolint:exhaustive
94+
switch s := creds.Source; s {
9595
case xpv1.CredentialsSourceSecret:
9696
csr := creds.SecretRef
9797
if csr == nil {

0 commit comments

Comments
 (0)