Skip to content

Commit 24259ca

Browse files
committed
migrate golangci-lint to v2.0.2
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent d2c9f1e commit 24259ca

File tree

5 files changed

+75
-61
lines changed

5 files changed

+75
-61
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ jobs:
3737
go-version: ${{ matrix.go-version }}
3838
check-latest: true
3939
cache: true
40-
- uses: golangci/golangci-lint-action@v6
40+
- uses: golangci/golangci-lint-action@v7
4141
with:
42-
version: v1.64.2
42+
version: v2.0.2
4343
args: --verbose
4444
skip-cache: true
4545
- name: Test

.golangci.yml

+66-53
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1-
issues:
2-
max-issues-per-linter: 0
3-
max-same-issues: 0
1+
version: "2"
42
linters:
5-
disable-all: true
3+
default: none
64
enable:
75
- copyloopvar
86
- depguard
97
- errcheck
108
- errorlint
119
- gocritic
1210
- gocyclo
13-
- gofumpt
14-
- goimports
1511
- gomodguard
16-
- revive
17-
- gosimple
1812
- govet
1913
- ineffassign
2014
- lll
@@ -24,51 +18,70 @@ linters:
2418
- revive
2519
- staticcheck
2620
- testifylint
27-
- typecheck
2821
- unconvert
2922
- unparam
3023
- unused
31-
linters-settings:
32-
depguard:
33-
rules:
34-
all:
35-
deny:
36-
- pkg: gopkg.in/yaml.v2
37-
desc: 'compose-go uses yaml.v3'
38-
gocritic:
39-
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
40-
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
41-
enabled-tags:
42-
- diagnostic
43-
- opinionated
44-
- style
45-
disabled-checks:
46-
- paramTypeCombine
47-
- unnamedResult
48-
- whyNoLint
49-
gomodguard:
50-
blocked:
51-
modules:
52-
- github.com/pkg/errors:
53-
recommendations:
54-
- errors
55-
- fmt
56-
lll:
57-
line-length: 200
58-
testifylint:
59-
disable:
60-
- float-compare
61-
- go-require
62-
enable:
63-
- bool-compare
64-
- compares
65-
- empty
66-
- error-is-as
67-
- error-nil
68-
- expected-actual
69-
- len
70-
- require-error
71-
- suite-dont-use-pkg
72-
- suite-extra-assert-call
73-
run:
74-
timeout: 5m
24+
settings:
25+
depguard:
26+
rules:
27+
all:
28+
deny:
29+
- pkg: gopkg.in/yaml.v2
30+
desc: compose-go uses yaml.v3
31+
gocritic:
32+
disabled-checks:
33+
- paramTypeCombine
34+
- unnamedResult
35+
- whyNoLint
36+
enabled-tags:
37+
- diagnostic
38+
- opinionated
39+
- style
40+
gomodguard:
41+
blocked:
42+
modules:
43+
- github.com/pkg/errors:
44+
recommendations:
45+
- errors
46+
- fmt
47+
lll:
48+
line-length: 200
49+
testifylint:
50+
enable:
51+
- bool-compare
52+
- compares
53+
- empty
54+
- error-is-as
55+
- error-nil
56+
- expected-actual
57+
- len
58+
- require-error
59+
- suite-dont-use-pkg
60+
- suite-extra-assert-call
61+
disable:
62+
- float-compare
63+
- go-require
64+
exclusions:
65+
generated: lax
66+
presets:
67+
- comments
68+
- common-false-positives
69+
- legacy
70+
- std-error-handling
71+
paths:
72+
- third_party$
73+
- builtin$
74+
- examples$
75+
issues:
76+
max-issues-per-linter: 0
77+
max-same-issues: 0
78+
formatters:
79+
enable:
80+
- gofumpt
81+
- goimports
82+
exclusions:
83+
generated: lax
84+
paths:
85+
- third_party$
86+
- builtin$
87+
- examples$

dotenv/env.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func GetEnvFromFile(currentEnv map[string]string, filenames []string) (map[strin
3535

3636
s, err := os.Stat(dotEnvFile)
3737
if os.IsNotExist(err) {
38-
return envMap, fmt.Errorf("Couldn't find env file: %s", dotEnvFile)
38+
return envMap, fmt.Errorf("couldn't find env file: %s", dotEnvFile)
3939
}
4040
if err != nil {
4141
return envMap, err
@@ -50,7 +50,7 @@ func GetEnvFromFile(currentEnv map[string]string, filenames []string) (map[strin
5050

5151
b, err := os.ReadFile(dotEnvFile)
5252
if os.IsNotExist(err) {
53-
return nil, fmt.Errorf("Couldn't read env file: %s", dotEnvFile)
53+
return nil, fmt.Errorf("couldn't read env file: %s", dotEnvFile)
5454
}
5555
if err != nil {
5656
return envMap, err

loader/loader.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ func LoadModelWithContext(ctx context.Context, configDetails types.ConfigDetails
337337
// LoadModelWithContext reads a ConfigDetails and returns a fully loaded configuration as a yaml dictionary
338338
func loadModelWithContext(ctx context.Context, configDetails *types.ConfigDetails, opts *Options) (map[string]any, error) {
339339
if len(configDetails.ConfigFiles) < 1 {
340-
return nil, errors.New("No files specified")
340+
return nil, errors.New("no compose file specified")
341341
}
342342

343343
err := projectName(configDetails, opts)
@@ -877,7 +877,7 @@ func formatInvalidKeyError(keyPrefix string, key interface{}) error {
877877
} else {
878878
location = fmt.Sprintf("in %s", keyPrefix)
879879
}
880-
return fmt.Errorf("Non-string key %s: %#v", location, key)
880+
return fmt.Errorf("non-string key %s: %#v", location, key)
881881
}
882882

883883
// Windows path, c:\\my\\path\\shiny, need to be changed to be compatible with

types/project.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,10 @@ func (p *Project) ServicesWithCapabilities() ([]string, []string, []string) {
157157
capabilities = append(capabilities, service.Name)
158158
}
159159
for _, c := range d.Capabilities {
160-
if c == "gpu" {
160+
switch c {
161+
case "gpu":
161162
gpu = append(gpu, service.Name)
162-
} else if c == "tpu" {
163+
case "tpu":
163164
tpu = append(tpu, service.Name)
164165
}
165166
}

0 commit comments

Comments
 (0)