Skip to content

Commit 25794f7

Browse files
committed
build: bump go version to v1.24.9 and golangci-lint to v2.4.0
- .golangci.yml config file migrated with golangci-lint migrate Signed-off-by: Jared Watts <[email protected]>
1 parent d27ce5b commit 25794f7

File tree

2 files changed

+135
-197
lines changed

2 files changed

+135
-197
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ on:
1414

1515
env:
1616
# Common versions
17-
GO_VERSION: '1.23.1'
18-
GOLANGCI_VERSION: 'v1.61.0'
17+
GO_VERSION: '1.24.9'
18+
GOLANGCI_VERSION: 'v2.4.0'
1919
DOCKER_BUILDX_VERSION: 'v0.24.0'
2020

2121
# These environment variables are important to the Crossplane CLI install.sh

.golangci.yml

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

0 commit comments

Comments
 (0)