Skip to content

Commit 1f68c03

Browse files
committed
Upgrade golangci-lint from v1.64.8 to v2.8.0
Upgrade golangci-lint and apply changes recommended by linter.
1 parent 17c203e commit 1f68c03

10 files changed

Lines changed: 78 additions & 66 deletions

File tree

.golangci.yml

Lines changed: 59 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,68 @@
1-
run:
2-
deadline: 60s
3-
1+
version: "2"
42
linters:
3+
default: standard
54
enable:
65
- contextcheck
7-
- gci
8-
- gofumpt
96
- gosec
107
- importas
118
- intrange
129
- misspell
1310
- tparallel
1411
- unparam
15-
16-
issues:
17-
exclude-dirs:
18-
- hack
19-
exclude-rules:
20-
- path: _test\.go
21-
linters:
22-
- errcheck
23-
24-
linters-settings:
25-
gci:
26-
no-inline-comments: true
27-
no-prefix-comments: false
28-
sections:
29-
- standard
30-
- default
31-
- prefix(github.com/artefactual-sdps/preprocessing-base)
32-
section-separators:
33-
- newLine
34-
gofumpt:
35-
extra-rules: true
36-
importas:
37-
no-unaliased: true
38-
no-extra-aliases: false
39-
alias:
40-
- pkg: go.temporal.io/sdk/contrib/(\w+)
41-
alias: temporalsdk_contrib_$1
42-
- pkg: go.temporal.io/sdk/(\w+)
43-
alias: temporalsdk_$1
44-
- pkg: go.temporal.io/api/(\w+)
45-
alias: temporalapi_$1
46-
gosec:
47-
exclude-generated: false
48-
severity: low
49-
confidence: low
12+
settings:
13+
gosec:
14+
severity: low
15+
confidence: low
16+
importas:
17+
alias:
18+
- pkg: go.temporal.io/sdk/contrib/(\w+)
19+
alias: temporalsdk_contrib_$1
20+
- pkg: go.temporal.io/sdk/(\w+)
21+
alias: temporalsdk_$1
22+
- pkg: go.temporal.io/api/(\w+)
23+
alias: temporalapi_$1
24+
no-unaliased: true
25+
no-extra-aliases: false
26+
exclusions:
27+
generated: lax
28+
presets:
29+
- comments
30+
- common-false-positives
31+
- legacy
32+
- std-error-handling
33+
rules:
34+
- linters:
35+
- errcheck
36+
path: _test\.go
37+
paths:
38+
- hack
39+
- third_party$
40+
- builtin$
41+
- examples$
42+
formatters:
43+
enable:
44+
- gci
45+
- gofumpt
46+
- golines
47+
settings:
48+
gci:
49+
sections:
50+
- standard
51+
- default
52+
- prefix(github.com/artefactual-sdps/preprocessing-base)
53+
no-inline-comments: true
54+
no-prefix-comments: false
55+
gofumpt:
56+
extra-rules: true
57+
golines:
58+
max-len: 120
59+
shorten-comments: true
60+
reformat-tags: true
61+
chain-split-dots: true
62+
exclusions:
63+
generated: lax
64+
paths:
65+
- hack
66+
- third_party$
67+
- builtin$
68+
- examples$

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ help:
8585
'
8686

8787
lint: # @HELP Lint the project Go files with golangci-lint.
88-
lint: OUT_FORMAT ?= colored-line-number
89-
lint: LINT_FLAGS ?= --timeout=5m --fix
88+
lint: LINT_FLAGS ?= --timeout=5m --fix --output.text.colors
9089
lint: $(GOLANGCI_LINT)
91-
golangci-lint run --out-format $(OUT_FORMAT) $(LINT_FLAGS)
90+
golangci-lint run $(LINT_FLAGS)
9291

9392
list-tested-packages: # @HELP Print a list of packages being tested.
9493
list-tested-packages:

cmd/worker/main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ import (
88
"os/signal"
99
"runtime"
1010

11-
"github.com/spf13/pflag"
12-
"go.artefactual.dev/tools/log"
13-
1411
"github.com/artefactual-sdps/preprocessing-base/cmd/worker/workercmd"
1512
"github.com/artefactual-sdps/preprocessing-base/internal/config"
1613
"github.com/artefactual-sdps/preprocessing-base/internal/version"
14+
"github.com/spf13/pflag"
15+
"go.artefactual.dev/tools/log"
1716
)
1817

1918
const appName = "preprocessing-base-worker"

cmd/worker/workercmd/cmd.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package workercmd
33
import (
44
"context"
55

6+
"github.com/artefactual-sdps/preprocessing-base/internal/config"
7+
"github.com/artefactual-sdps/preprocessing-base/internal/workflow"
68
"github.com/artefactual-sdps/temporal-activities/bagcreate"
79
"github.com/go-logr/logr"
810
"go.artefactual.dev/tools/temporal"
@@ -11,9 +13,6 @@ import (
1113
temporalsdk_interceptor "go.temporal.io/sdk/interceptor"
1214
temporalsdk_worker "go.temporal.io/sdk/worker"
1315
temporalsdk_workflow "go.temporal.io/sdk/workflow"
14-
15-
"github.com/artefactual-sdps/preprocessing-base/internal/config"
16-
"github.com/artefactual-sdps/preprocessing-base/internal/workflow"
1716
)
1817

1918
const Name = "preprocessing-worker"

hack/make/dep_golangci_lint.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ $(call _assert_var,UNAME_ARCH)
55
$(call _assert_var,CACHE_VERSIONS)
66
$(call _assert_var,CACHE_BIN)
77

8-
GOLANGCI_LINT_VERSION ?= 1.64.8
8+
GOLANGCI_LINT_VERSION ?= 2.8.0
99

1010
ARCH := $(UNAME_ARCH)
1111
ifeq ($(UNAME_ARCH),x86_64)

internal/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func Read(config *Configuration, configFile string) (found bool, configFileUsed
128128
}
129129

130130
if err := config.Validate(); err != nil {
131-
return true, "", errors.Join(errors.New("invalid configuration:"), err)
131+
return true, "", errors.Join(errors.New("invalid configuration"), err)
132132
}
133133

134134
return true, v.ConfigFileUsed(), nil

internal/config/config_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ package config_test
33
import (
44
"testing"
55

6+
"github.com/artefactual-sdps/preprocessing-base/internal/config"
67
"github.com/artefactual-sdps/temporal-activities/bagcreate"
78
"gotest.tools/v3/assert"
89
"gotest.tools/v3/fs"
9-
10-
"github.com/artefactual-sdps/preprocessing-base/internal/config"
1110
)
1211

1312
const testConfig = `# Config
@@ -66,7 +65,7 @@ func TestConfig(t *testing.T) {
6665
name: "Errors when configuration values are not valid",
6766
configFile: "preprocessing.toml",
6867
wantFound: true,
69-
wantErr: `invalid configuration:
68+
wantErr: `invalid configuration
7069
SharedPath: missing required value
7170
Temporal.TaskQueue: missing required value
7271
Temporal.WorkflowName: missing required value`,
@@ -83,7 +82,7 @@ workflowName = "preprocessing"
8382
maxConcurrentSessions = -1
8483
`,
8584
wantFound: true,
86-
wantErr: `invalid configuration:
85+
wantErr: `invalid configuration
8786
Worker.MaxConcurrentSessions: -1 is less than the minimum value (1)`,
8887
},
8988
{
@@ -98,7 +97,7 @@ workflowName = "preprocessing"
9897
checksumAlgorithm = "unknown"
9998
`,
10099
wantFound: true,
101-
wantErr: `invalid configuration:
100+
wantErr: `invalid configuration
102101
Bagit.ChecksumAlgorithm: invalid value "unknown", must be one of (md5, sha1, sha256, sha512)`,
103102
},
104103
{

internal/eventlog/eventlog_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import (
55
"testing"
66
"time"
77

8-
"gotest.tools/v3/assert"
9-
108
"github.com/artefactual-sdps/preprocessing-base/internal/enums"
119
"github.com/artefactual-sdps/preprocessing-base/internal/eventlog"
10+
"gotest.tools/v3/assert"
1211
)
1312

1413
func TestEvent(t *testing.T) {

internal/workflow/preprocessing.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ import (
55
"path/filepath"
66
"time"
77

8+
"github.com/artefactual-sdps/preprocessing-base/internal/enums"
9+
"github.com/artefactual-sdps/preprocessing-base/internal/eventlog"
810
"github.com/artefactual-sdps/temporal-activities/bagcreate"
911
"go.artefactual.dev/tools/temporal"
1012
temporalsdk_temporal "go.temporal.io/sdk/temporal"
1113
temporalsdk_workflow "go.temporal.io/sdk/workflow"
12-
13-
"github.com/artefactual-sdps/preprocessing-base/internal/enums"
14-
"github.com/artefactual-sdps/preprocessing-base/internal/eventlog"
1514
)
1615

1716
type Outcome int

internal/workflow/preprocessing_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@ import (
55
"path/filepath"
66
"testing"
77

8+
"github.com/artefactual-sdps/preprocessing-base/internal/config"
9+
"github.com/artefactual-sdps/preprocessing-base/internal/enums"
10+
"github.com/artefactual-sdps/preprocessing-base/internal/eventlog"
11+
"github.com/artefactual-sdps/preprocessing-base/internal/workflow"
812
"github.com/artefactual-sdps/temporal-activities/bagcreate"
913
"github.com/stretchr/testify/mock"
1014
"github.com/stretchr/testify/suite"
1115
temporalsdk_activity "go.temporal.io/sdk/activity"
1216
temporalsdk_testsuite "go.temporal.io/sdk/testsuite"
1317
temporalsdk_worker "go.temporal.io/sdk/worker"
14-
15-
"github.com/artefactual-sdps/preprocessing-base/internal/config"
16-
"github.com/artefactual-sdps/preprocessing-base/internal/enums"
17-
"github.com/artefactual-sdps/preprocessing-base/internal/eventlog"
18-
"github.com/artefactual-sdps/preprocessing-base/internal/workflow"
1918
)
2019

2120
const sharedPath = "/shared/path/"

0 commit comments

Comments
 (0)