Skip to content

Commit fa31ebc

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 fa31ebc

6 files changed

Lines changed: 67 additions & 48 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:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ To create a new preprocessing child workflow project:
2828
- The default Docker image name
2929
- The Makefile project name and the location of the installed tools
3030
- The `appName` in the worker command
31+
- The gci "prefix" section in the `.golangci.yml` config file
3132
- Update this readme file:
3233
- Change the heading and initial description
3334
- Remove the first three sections from the list above and the content

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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestConfig(t *testing.T) {
6666
name: "Errors when configuration values are not valid",
6767
configFile: "preprocessing.toml",
6868
wantFound: true,
69-
wantErr: `invalid configuration:
69+
wantErr: `invalid configuration
7070
SharedPath: missing required value
7171
Temporal.TaskQueue: missing required value
7272
Temporal.WorkflowName: missing required value`,
@@ -83,7 +83,7 @@ workflowName = "preprocessing"
8383
maxConcurrentSessions = -1
8484
`,
8585
wantFound: true,
86-
wantErr: `invalid configuration:
86+
wantErr: `invalid configuration
8787
Worker.MaxConcurrentSessions: -1 is less than the minimum value (1)`,
8888
},
8989
{
@@ -98,7 +98,7 @@ workflowName = "preprocessing"
9898
checksumAlgorithm = "unknown"
9999
`,
100100
wantFound: true,
101-
wantErr: `invalid configuration:
101+
wantErr: `invalid configuration
102102
Bagit.ChecksumAlgorithm: invalid value "unknown", must be one of (md5, sha1, sha256, sha512)`,
103103
},
104104
{

0 commit comments

Comments
 (0)