Skip to content

Commit 3ab459e

Browse files
authored
fix: more revive rules (#8814)
Signed-off-by: Matthieu MOREL <[email protected]>
1 parent 296eb3c commit 3ab459e

File tree

18 files changed

+65
-103
lines changed

18 files changed

+65
-103
lines changed

.golangci.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,28 @@ linters:
9191
max-open-files: 2048
9292
# https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md
9393
rules:
94+
- name: bool-literal-in-expr
95+
- name: context-as-argument
96+
arguments:
97+
- allowTypesBefore: "*testing.T"
98+
- name: duplicated-imports
9499
- name: early-return
95100
arguments:
96101
- preserve-scope
102+
- name: if-return
103+
- name: increment-decrement
97104
- name: indent-error-flow
98105
arguments:
99106
- preserve-scope
107+
- name: range
108+
- name: range-val-address
100109
- name: superfluous-else
101110
arguments:
102111
- preserve-scope
112+
- name: time-equal
113+
- name: unnecessary-stmt
103114
- name: unused-parameter
115+
- name: use-any
104116

105117
testifylint:
106118
enable-all: true

cmd/trivy/main.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,5 @@ func run() error {
4242
}
4343

4444
app := commands.NewApp()
45-
if err := app.Execute(); err != nil {
46-
return err
47-
}
48-
return nil
45+
return app.Execute()
4946
}

go.mod

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ require (
2020
github.com/aquasecurity/go-pep440-version v0.0.1
2121
github.com/aquasecurity/go-version v0.0.1
2222
github.com/aquasecurity/iamgo v0.0.10
23-
github.com/aquasecurity/jfather v0.0.8 // indirect
2423
github.com/aquasecurity/table v1.8.0
2524
github.com/aquasecurity/testdocker v0.0.0-20240730042311-4642e94c7fc8
2625
github.com/aquasecurity/tml v0.6.1
@@ -49,8 +48,6 @@ require (
4948
github.com/fatih/color v1.18.0
5049
github.com/go-git/go-git/v5 v5.15.0
5150
github.com/go-json-experiment/json v0.0.0-20250223041408-d3c622f1b874 // Replace with encoding/json/v2 when proposal is accepted. Track https://github.com/golang/go/issues/71497
52-
github.com/go-openapi/runtime v0.28.0 // indirect
53-
github.com/go-openapi/strfmt v0.23.0 // indirect
5451
github.com/go-redis/redis/v8 v8.11.5
5552
github.com/gocsaf/csaf/v3 v3.2.0
5653
github.com/golang-jwt/jwt/v5 v5.2.2
@@ -94,7 +91,6 @@ require (
9491
github.com/openvex/discovery v0.1.1-0.20240802171711-7c54efc57553
9592
github.com/openvex/go-vex v0.2.5
9693
github.com/owenrumney/go-sarif/v2 v2.3.3
97-
github.com/owenrumney/squealer v1.2.11 // indirect
9894
github.com/package-url/packageurl-go v0.1.3
9995
github.com/quasilyte/go-ruleguard/dsl v0.3.22
10096
github.com/rust-secure-code/go-rustaudit v0.0.0-20250226111315-e20ec32e963c
@@ -120,7 +116,6 @@ require (
120116
github.com/zclconf/go-cty-yaml v1.1.0
121117
go.etcd.io/bbolt v1.4.0
122118
golang.org/x/crypto v0.37.0
123-
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
124119
golang.org/x/mod v0.24.0
125120
golang.org/x/net v0.39.0
126121
golang.org/x/sync v0.13.0
@@ -134,7 +129,6 @@ require (
134129
k8s.io/api v0.33.0
135130
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738
136131
modernc.org/sqlite v1.37.0
137-
sigs.k8s.io/yaml v1.4.0 // indirect
138132
)
139133

140134
require (
@@ -174,10 +168,23 @@ require (
174168
github.com/VividCortex/ewma v1.2.0 // indirect
175169
github.com/agext/levenshtein v1.2.3 // indirect
176170
github.com/agnivade/levenshtein v1.2.1 // indirect
171+
github.com/alessio/shellescape v1.4.1 // indirect
177172
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 // indirect
178173
github.com/anchore/go-struct-converter v0.0.0-20221118182256-c68fdcfa2092 // indirect
179174
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
175+
github.com/aquasecurity/jfather v0.0.8 // indirect
180176
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
177+
github.com/aws/aws-sdk-go v1.55.7 // indirect
178+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 // indirect
179+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 // indirect
180+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34 // indirect
181+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect
182+
github.com/aws/aws-sdk-go-v2/service/ebs v1.22.1 // indirect
183+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 // indirect
184+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 // indirect
185+
github.com/aws/aws-sdk-go-v2/service/sso v1.25.3 // indirect
186+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1 // indirect
187+
github.com/aws/aws-sdk-go-v2/service/sts v1.33.19 // indirect
181188
github.com/beorn7/perks v1.0.1 // indirect
182189
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
183190
github.com/blang/semver v3.5.1+incompatible // indirect
@@ -214,10 +221,13 @@ require (
214221
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
215222
github.com/dsnet/compress v0.0.2-0.20230904184137-39efe44ab707 // indirect
216223
github.com/dustin/go-humanize v1.0.1 // indirect
224+
github.com/ebitengine/purego v0.8.2 // indirect
217225
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
218226
github.com/emirpasic/gods v1.18.1 // indirect
227+
github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect
219228
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
220229
github.com/evanphx/json-patch v5.9.0+incompatible // indirect
230+
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
221231
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
222232
github.com/felixge/httpsnoop v1.0.4 // indirect
223233
github.com/fsnotify/fsnotify v1.8.0 // indirect
@@ -237,9 +247,12 @@ require (
237247
github.com/go-openapi/jsonpointer v0.21.0 // indirect
238248
github.com/go-openapi/jsonreference v0.21.0 // indirect
239249
github.com/go-openapi/loads v0.22.0 // indirect
250+
github.com/go-openapi/runtime v0.28.0 // indirect
240251
github.com/go-openapi/spec v0.21.0 // indirect
252+
github.com/go-openapi/strfmt v0.23.0 // indirect
241253
github.com/go-openapi/swag v0.23.1 // indirect
242254
github.com/go-openapi/validate v0.24.0 // indirect
255+
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
243256
github.com/gobwas/glob v0.2.3 // indirect
244257
github.com/goccy/go-yaml v1.15.23 // indirect
245258
github.com/gofrs/uuid v4.3.1+incompatible // indirect
@@ -251,9 +264,12 @@ require (
251264
github.com/google/certificate-transparency-go v1.1.8 // indirect
252265
github.com/google/gnostic-models v0.6.9 // indirect
253266
github.com/google/go-cmp v0.7.0 // indirect
267+
github.com/google/go-github/v31 v31.0.0 // indirect
254268
github.com/google/go-querystring v1.1.0 // indirect
255269
github.com/google/s2a-go v0.1.9 // indirect
270+
github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 // indirect
256271
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
272+
github.com/google/subcommands v1.2.0 // indirect
257273
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
258274
github.com/googleapis/gax-go/v2 v2.14.1 // indirect
259275
github.com/gorilla/mux v1.8.1 // indirect
@@ -275,6 +291,7 @@ require (
275291
github.com/json-iterator/go v1.1.12 // indirect
276292
github.com/kevinburke/ssh_config v1.2.0 // indirect
277293
github.com/klauspost/compress v1.18.0 // indirect
294+
github.com/knqyf263/labeler v0.0.0-20200423181506-7a6e545148c3 // indirect
278295
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
279296
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
280297
github.com/letsencrypt/boulder v0.0.0-20240620165639-de9c06129bec // indirect
@@ -292,9 +309,11 @@ require (
292309
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
293310
github.com/mitchellh/reflectwalk v1.0.2 // indirect
294311
github.com/moby/docker-image-spec v1.3.1 // indirect
312+
github.com/moby/go-archive v0.1.0 // indirect
295313
github.com/moby/locker v1.0.1 // indirect
296314
github.com/moby/patternmatcher v0.6.0 // indirect
297315
github.com/moby/spdystream v0.5.0 // indirect
316+
github.com/moby/sys/atomicwriter v0.1.0 // indirect
298317
github.com/moby/sys/mountinfo v0.7.2 // indirect
299318
github.com/moby/sys/sequential v0.6.0 // indirect
300319
github.com/moby/sys/signal v0.7.1 // indirect
@@ -310,9 +329,12 @@ require (
310329
github.com/ncruces/go-strftime v0.1.9 // indirect
311330
github.com/nozzle/throttler v0.0.0-20180817012639-2ea982251481 // indirect
312331
github.com/oklog/ulid v1.3.1 // indirect
332+
github.com/oklog/ulid/v2 v2.1.0 // indirect
313333
github.com/opencontainers/runtime-spec v1.2.0 // indirect
314334
github.com/opencontainers/selinux v1.11.1 // indirect
315335
github.com/opentracing/opentracing-go v1.2.0 // indirect
336+
github.com/owenrumney/squealer v1.2.11 // indirect
337+
github.com/pelletier/go-toml v1.9.5 // indirect
316338
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
317339
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
318340
github.com/pjbgf/sha1cd v0.3.2 // indirect
@@ -331,12 +353,15 @@ require (
331353
github.com/rubenv/sql-migrate v1.7.1 // indirect
332354
github.com/russross/blackfriday/v2 v2.1.0 // indirect
333355
github.com/sagikazarmark/locafero v0.7.0 // indirect
356+
github.com/samber/oops v1.15.0 // indirect
334357
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect
335358
github.com/sassoftware/relic v7.2.1+incompatible // indirect
336359
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
337360
github.com/shibumi/go-pathspec v1.3.0 // indirect
361+
github.com/shirou/gopsutil/v4 v4.25.1 // indirect
338362
github.com/shopspring/decimal v1.4.0 // indirect
339363
github.com/sigstore/cosign/v2 v2.2.4 // indirect
364+
github.com/sigstore/protobuf-specs v0.4.1 // indirect
340365
github.com/sigstore/sigstore v1.9.1 // indirect
341366
github.com/sigstore/timestamp-authority v1.2.2 // indirect
342367
github.com/skeema/knownhosts v1.3.1 // indirect
@@ -350,6 +375,7 @@ require (
350375
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 // indirect
351376
github.com/tklauser/go-sysconf v0.3.13 // indirect
352377
github.com/tklauser/numcpus v0.7.0 // indirect
378+
github.com/tonglil/versioning v0.0.0-20170205083536-8b2a4334bd1d // indirect
353379
github.com/tonistiigi/go-csvvalue v0.0.0-20240710180619-ddb21b71c0b4 // indirect
354380
github.com/transparency-dev/merkle v0.0.2 // indirect
355381
github.com/ulikunitz/xz v0.5.12 // indirect
@@ -377,6 +403,7 @@ require (
377403
go.opentelemetry.io/otel/trace v1.35.0 // indirect
378404
go.uber.org/multierr v1.11.0 // indirect
379405
go.uber.org/zap v1.27.0 // indirect
406+
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
380407
golang.org/x/oauth2 v0.28.0 // indirect
381408
golang.org/x/sys v0.32.0 // indirect
382409
golang.org/x/telemetry v0.0.0-20240522233618-39ace7a40ae7 // indirect
@@ -391,6 +418,7 @@ require (
391418
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
392419
gopkg.in/inf.v0 v0.9.1 // indirect
393420
gopkg.in/warnings.v0 v0.1.2 // indirect
421+
gopkg.in/yaml.v2 v2.4.0 // indirect
394422
k8s.io/apiextensions-apiserver v0.32.2 // indirect
395423
k8s.io/apimachinery v0.33.0 // indirect
396424
k8s.io/apiserver v0.32.2 // indirect
@@ -406,43 +434,12 @@ require (
406434
mvdan.cc/sh/v3 v3.11.0 // indirect
407435
oras.land/oras-go v1.2.5 // indirect
408436
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
437+
sigs.k8s.io/kind v0.19.0 // indirect
409438
sigs.k8s.io/kustomize/api v0.19.0 // indirect
410439
sigs.k8s.io/kustomize/kyaml v0.19.0 // indirect
411-
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
412-
)
413-
414-
require (
415-
github.com/alessio/shellescape v1.4.1 // indirect
416-
github.com/aws/aws-sdk-go v1.55.7 // indirect
417-
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 // indirect
418-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 // indirect
419-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34 // indirect
420-
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect
421-
github.com/aws/aws-sdk-go-v2/service/ebs v1.22.1 // indirect
422-
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 // indirect
423-
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 // indirect
424-
github.com/aws/aws-sdk-go-v2/service/sso v1.25.3 // indirect
425-
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1 // indirect
426-
github.com/aws/aws-sdk-go-v2/service/sts v1.33.19 // indirect
427-
github.com/ebitengine/purego v0.8.2 // indirect
428-
github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect
429-
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
430-
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
431-
github.com/google/go-github/v31 v31.0.0 // indirect
432-
github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 // indirect
433-
github.com/google/subcommands v1.2.0 // indirect
434-
github.com/knqyf263/labeler v0.0.0-20200423181506-7a6e545148c3 // indirect
435-
github.com/moby/go-archive v0.1.0 // indirect
436-
github.com/moby/sys/atomicwriter v0.1.0 // indirect
437-
github.com/oklog/ulid/v2 v2.1.0 // indirect
438-
github.com/pelletier/go-toml v1.9.5 // indirect
439-
github.com/samber/oops v1.15.0 // indirect
440-
github.com/shirou/gopsutil/v4 v4.25.1 // indirect
441-
github.com/sigstore/protobuf-specs v0.4.1 // indirect
442-
github.com/tonglil/versioning v0.0.0-20170205083536-8b2a4334bd1d // indirect
443-
gopkg.in/yaml.v2 v2.4.0 // indirect
444-
sigs.k8s.io/kind v0.19.0 // indirect
445440
sigs.k8s.io/randfill v1.0.0 // indirect
441+
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
442+
sigs.k8s.io/yaml v1.4.0 // indirect
446443
)
447444

448445
tool (

magefiles/fixture.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ func fixtureContainerImages() error {
3838
}
3939

4040
// Save trivy-test-images/containerd image
41-
if err := saveImage("containerd", "latest"); err != nil {
42-
return err
43-
}
44-
return nil
41+
return saveImage("containerd", "latest")
4542
}
4643

4744
func saveImage(subpath, tag string) error {
@@ -65,10 +62,7 @@ func saveImage(subpath, tag string) error {
6562
if err = crane.Save(img, imgName, tarPath); err != nil {
6663
return err
6764
}
68-
if err = sh.Run("gzip", tarPath); err != nil {
69-
return err
70-
}
71-
return nil
65+
return sh.Run("gzip", tarPath)
7266
}
7367

7468
func fixtureVMImages() error {

magefiles/magefile.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,19 +189,13 @@ func (Test) FixtureTerraformPlanSnapshots() error {
189189
// GenerateModules compiles WASM modules for unit tests
190190
func (Test) GenerateModules() error {
191191
pattern := filepath.Join("pkg", "module", "testdata", "*", "*.go")
192-
if err := compileWasmModules(pattern); err != nil {
193-
return err
194-
}
195-
return nil
192+
return compileWasmModules(pattern)
196193
}
197194

198195
// GenerateExampleModules compiles example Wasm modules for integration tests
199196
func (Test) GenerateExampleModules() error {
200197
pattern := filepath.Join("examples", "module", "*", "*.go")
201-
if err := compileWasmModules(pattern); err != nil {
202-
return err
203-
}
204-
return nil
198+
return compileWasmModules(pattern)
205199
}
206200

207201
// UpdateGolden updates golden files for integration tests

pkg/dependency/parser/nodejs/pnpm/parse.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ func (p *Parser) markRootPkgs(id string, pkgs map[string]ftypes.Package, deps ma
245245
for _, depID := range deps[id].DependsOn {
246246
p.markRootPkgs(depID, pkgs, deps, visited)
247247
}
248-
return
249248
}
250249

251250
func (p *Parser) parseLockfileVersion(lockFile LockFile) float64 {

pkg/fanal/secret/scanner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func (r *Rule) MatchKeywords(content []byte) bool {
175175
if len(r.Keywords) == 0 {
176176
return true
177177
}
178-
var contentLower = bytes.ToLower(content)
178+
contentLower := bytes.ToLower(content)
179179
for _, kw := range r.Keywords {
180180
if bytes.Contains(contentLower, []byte(strings.ToLower(kw))) {
181181
return true
@@ -499,7 +499,7 @@ func findLocation(start, end int, content []byte) (int, int, types.Code, string)
499499
if lineStart == -1 {
500500
lineStart = 0
501501
} else {
502-
lineStart += 1
502+
lineStart++
503503
}
504504

505505
lineEnd := bytes.Index(content[start:], lineSep)

pkg/flag/options.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,7 @@ func (f *Flag[T]) Bind(cmd *cobra.Command) error {
312312
}
313313

314314
// Bind environmental variable
315-
if err := f.BindEnv(); err != nil {
316-
return err
317-
}
318-
319-
return nil
315+
return f.BindEnv()
320316
}
321317

322318
func (f *Flag[T]) BindEnv() error {

pkg/iac/scanners/azure/arm/parser/armjson/unmarshal.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,15 @@ func Unmarshal(data []byte, target any, metadata *types.Metadata) error {
2020
if err != nil {
2121
return err
2222
}
23-
if err := node.Decode(target); err != nil {
24-
return err
25-
}
2623

27-
return nil
24+
return node.Decode(target)
2825
}
2926

3027
func UnmarshalFromReader(r io.ReadSeeker, target any, metadata *types.Metadata) error {
3128
node, err := newParser(NewPeekReader(r), Position{1, 1}).parse(metadata)
3229
if err != nil {
3330
return err
3431
}
35-
if err := node.Decode(target); err != nil {
36-
return err
37-
}
3832

39-
return nil
33+
return node.Decode(target)
4034
}

pkg/iac/scanners/cloudformation/parser/property.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ func (p *Property) UnmarshalYAML(node *yaml.Node) error {
9696
p.StartLine = node.Line
9797
p.EndLine = calculateEndLine(node)
9898
p.comment = node.LineComment
99-
if err := setPropertyValueFromYaml(node, p); err != nil {
100-
return err
101-
}
102-
return nil
99+
return setPropertyValueFromYaml(node, p)
103100
}
104101

105102
func (p *Property) UnmarshalJSONFrom(dec *jsontext.Decoder) error {

0 commit comments

Comments
 (0)