Skip to content

Commit eaa954f

Browse files
authored
golangci-lint updates and build maintenance (#363)
build: revert update of golangci-lint runner version build: update github workflow for golangci-lint v1.64.8 build: update github workflows to checkout build: update golangci-lint to v1.64.8 chore: maintain .golangci.yml configuration --------- Signed-off-by: Ben Stickel <[email protected]>
1 parent 2ea4d75 commit eaa954f

File tree

7 files changed

+237
-297
lines changed

7 files changed

+237
-297
lines changed

.github/workflows/go.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ jobs:
3131
name: "Check go modules declaration"
3232
runs-on: ubuntu-latest
3333
steps:
34+
-
35+
name: Checkout code
36+
uses: actions/checkout@v4
3437
-
3538
name: Install Go
3639
uses: actions/setup-go@v5
3740
with:
3841
go-version-file: go.mod
39-
-
40-
name: Checkout code
41-
uses: actions/checkout@v4
4242
-
4343
name: Check go mod and go.sum
4444
run: |
@@ -82,16 +82,17 @@ jobs:
8282
name: "GolangCI-lint"
8383
runs-on: ubuntu-latest
8484
steps:
85+
-
86+
name: Checkout
87+
uses: actions/checkout@v4
8588
-
8689
name: Install Go
8790
uses: actions/setup-go@v5
8891
with:
8992
go-version-file: go.mod
90-
-
91-
uses: actions/checkout@v4
9293
-
9394
name: Lint code
94-
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
95+
uses: golangci/golangci-lint-action@4696ba8babb6127d732c3c6dde519db15edab9ea # v6.5.1
9596
with:
9697
version: latest
9798
args: --timeout=10m

.golangci.yml

+70-121
Original file line numberDiff line numberDiff line change
@@ -9,53 +9,70 @@ issues:
99
- ".*\\.resolvers\\.go$"
1010

1111
run:
12-
# default concurrency is a available CPU number
1312
concurrency: 4
14-
# timeout for analysis, e.g. 30s, 5m, default is 1m
15-
deadline: 20m
16-
# exit code when at least one issue was found, default is 1
13+
timeout: 20m
1714
issues-exit-code: 1
18-
# include test files or not, default is true
1915
tests: false
20-
21-
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
22-
# If invoked with -mod=readonly, the go command is disallowed from the implicit
23-
# automatic updating of go.mod described above. Instead, it fails when any changes
24-
# to go.mod are needed. This setting is most useful to check that go.mod does
25-
# not need updates, such as in a continuous integration and testing system.
26-
# If invoked with -mod=vendor, the go command assumes that the vendor
27-
# directory holds the correct copies of dependencies and ignores
28-
# the dependency descriptions in go.mod.
2916
modules-download-mode: readonly
30-
31-
# Allow multiple parallel golangci-lint instances running.
32-
# If false (default) - golangci-lint acquires file lock on start.
3317
allow-parallel-runners: false
3418

3519
# output configuration options
3620
output:
37-
# colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions
38-
# default is "colored-line-number"
39-
formats: colored-line-number
40-
41-
# print lines of code with issue, default is true
4221
print-issued-lines: true
43-
44-
# print linter name in the end of issue text, default is true
4522
print-linter-name: true
23+
sort-results: true
24+
sort-order:
25+
- linter
26+
- severity
27+
- file
28+
show-stats: true
4629

47-
# add a prefix to the output file references; default is no prefix
48-
path-prefix: ""
49-
50-
# sorts results by: filepath, line and column
51-
sort-results: false
30+
linters:
31+
enable:
32+
- bodyclose
33+
# - deadcode
34+
- depguard
35+
- dogsled
36+
# - dupl
37+
- errcheck
38+
- errorlint
39+
- copyloopvar
40+
- exhaustive
41+
- forbidigo
42+
- funlen
43+
# - gochecknoinits
44+
- goconst
45+
- gocritic
46+
- gocyclo
47+
- gofmt
48+
- govet
49+
- goheader
50+
- goimports
51+
- goprintffuncname
52+
- gosec
53+
- gosimple
54+
- ineffassign
55+
# - lll
56+
- misspell
57+
- nakedret
58+
- noctx
59+
- nolintlint
60+
- revive
61+
- rowserrcheck
62+
- staticcheck
63+
# - structcheck
64+
- stylecheck
65+
- typecheck
66+
- unconvert
67+
- unparam
68+
- unused
69+
# - varcheck
70+
- whitespace
5271

5372
linters-settings:
5473
dogsled:
55-
# checks assignments with too many blank identifiers; default is 2
5674
max-blank-identifiers: 2
5775
dupl:
58-
# tokens count to trigger issue, 150 by default
5976
threshold: 150
6077
depguard:
6178
rules:
@@ -104,11 +121,10 @@ linters-settings:
104121
- github.com/miscreant/miscreant.go
105122
- github.com/oklog/run
106123
- github.com/open-policy-agent/opa/rego
107-
- github.com/opencontainers/image-spec
108124
- github.com/opencontainers/go-digest
125+
- github.com/opencontainers/image-spec
109126
- github.com/ory/dockertest/v3
110127
- github.com/pelletier/go-toml
111-
- github.com/pelletier/go-toml
112128
- github.com/pierrec/lz4
113129
- github.com/pkg/errors
114130
- github.com/psanford/memfs
@@ -121,37 +137,35 @@ linters-settings:
121137
- github.com/xeipuuv/gojsonschema
122138
- github.com/zclconf/go-cty/cty
123139
- gitlab.com/NebulousLabs/merkletree
140+
- go.etcd.io/etcd
141+
- go.step.sm/crypto
142+
- go.uber.org/zap
143+
- golang.org/x/crypto
144+
- golang.org/x/oauth2
145+
- golang.org/x/ssh
146+
- golang.org/x/sync
147+
- golang.org/x/sys
148+
- golang.org/x/term
149+
- google.golang.org/genproto
150+
- google.golang.org/protobuf
151+
- gopkg.in/square/go-jose.v2
152+
- gopkg.in/yaml.v3
124153
- oras.land/oras-go
125154
- sigs.k8s.io/yaml
126155
- zntr.io/paseto/v3
127156
- zntr.io/paseto/v4
128157

129158
errcheck:
130-
# report about not checking of errors in type assertions: `a := b.(MyStruct)`;
131-
# default is false: such cases aren't reported by default.
132159
check-type-assertions: false
133-
134-
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
135-
# default is false: such cases aren't reported by default.
136160
check-blank: false
137-
138-
# [deprecated] comma-separated list of pairs of the form pkg:regex
139-
# the regex is used to ignore names within pkg. (default "fmt:.*").
140-
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
141-
exclude-functions: fmt:.*,io/ioutil:^Read.*
161+
exclude-functions:
162+
- fmt:.*
163+
- io/ioutil.Read.*
142164
exhaustive:
143-
# check switch statements in generated files also
144165
check-generated: false
145-
# indicates that switch statements are to be considered exhaustive if a
146-
# 'default' case is present, even if all enum members aren't listed in the
147-
# switch
148166
default-signifies-exhaustive: false
149-
govet:
150-
shadow: true
151167
goimports:
152-
local: "github.com/elastic"
153-
golint:
154-
min-confidence: 0.8
168+
local-prefixes: "github.com/elastic"
155169
gofmt:
156170
simplify: true
157171
gocyclo:
@@ -165,55 +179,34 @@ linters-settings:
165179
line-length: 140
166180
tab-width: 1
167181
gci:
168-
# put imports beginning with prefix after 3rd-party packages;
169-
# only support one prefix
170-
# if not set, use goimports.local-prefixes
171182
sections:
172183
- prefix(github.com/elastic)
173184
gocognit:
174-
# minimal code complexity to report, 30 by default (but we recommend 10-20)
175185
min-complexity: 20
176186
goconst:
177-
# minimal length of string constant, 3 by default
178187
min-len: 3
179-
# minimal occurrences count to trigger, 3 by default
180188
min-occurrences: 3
181189
nestif:
182-
# minimal complexity of if statements to report, 5 by default
183190
min-complexity: 4
184191
unused:
185-
# treat code as a program (not a library) and report unused exported identifiers; default is false.
186-
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
187-
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
188-
# with golangci-lint call it on a directory with the changed file.
189-
check-exported: false
192+
exported-fields-are-used: false
190193
unparam:
191-
# call graph construction algorithm (cha, rta). In general, use cha for libraries,
192-
# and rta for programs with main packages. Default is cha.
193-
algo: cha
194-
195-
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
196-
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
197-
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
198-
# with golangci-lint call it on a directory with the changed file.
199194
check-exported: false
200195
nakedret:
201196
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
202197
max-func-lines: 30
203198
prealloc:
204-
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
205-
# True by default.
206199
simple: true
207-
range-loops: true # Report preallocation suggestions on range loops, true by default
208-
for-loops: false # Report preallocation suggestions on for loops, false by default
200+
range-loops: true
201+
for-loops: false
209202
funlen:
210203
lines: 100
211204
statements: 50
212205
gomodguard:
213206
blocked:
214207
modules:
215208
- github.com/BurntSushi/toml:
216-
recommandations:
209+
recommendations:
217210
- github.com/pelletier/go-toml
218211
goheader:
219212
template: |-
@@ -234,53 +227,9 @@ linters-settings:
234227
specific language governing permissions and limitations
235228
under the License.
236229
gocritic:
237-
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
238-
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
239230
enabled-tags:
240231
- diagnostic
241232
- performance
242233
- style
243234
- opinionated
244235
- experimental
245-
246-
linters:
247-
enable:
248-
- bodyclose
249-
# - deadcode
250-
- depguard
251-
- dogsled
252-
# - dupl
253-
- errcheck
254-
- errorlint
255-
- copyloopvar
256-
- exhaustive
257-
- forbidigo
258-
- funlen
259-
# - gochecknoinits
260-
- goconst
261-
- gocritic
262-
- gocyclo
263-
- gofmt
264-
- goheader
265-
- goimports
266-
- goprintffuncname
267-
- gosec
268-
- gosimple
269-
- govet
270-
- ineffassign
271-
# - lll
272-
- misspell
273-
- nakedret
274-
- noctx
275-
- nolintlint
276-
- revive
277-
- rowserrcheck
278-
- staticcheck
279-
# - structcheck
280-
- stylecheck
281-
- typecheck
282-
- unconvert
283-
- unparam
284-
- unused
285-
# - varcheck
286-
- whitespace

go.mod

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/elastic/harp
22

3-
go 1.23.0
4-
5-
toolchain go1.23.4
3+
go 1.23.8
64

75
replace github.com/satori/go.uuid => github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b
86

pkg/bundle/ruleset/engine/cel/ext/package.go

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type packageLib struct{}
4444

4545
func (packageLib) CompileOptions() []cel.EnvOption {
4646
return []cel.EnvOption{
47+
//nolint:staticcheck // TODO: deprecated usage. Requires an update.
4748
cel.Declarations(
4849
decls.NewVar("p", harpPackageObjectType),
4950
decls.NewFunction("match_label",

pkg/bundle/ruleset/engine/cel/ext/secret.go

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type secretLib struct{}
4444

4545
func (secretLib) CompileOptions() []cel.EnvOption {
4646
return []cel.EnvOption{
47+
//nolint:staticcheck // TODO: deprecated usage. Requires an update.
4748
cel.Declarations(
4849
decls.NewFunction("is_base64",
4950
decls.NewInstanceOverload("kv_is_base64",

0 commit comments

Comments
 (0)