Skip to content

Commit 49260dc

Browse files
authored
Upgrade golangci-lint (#522)
- Run golangci-lint migrate - Fix staticcheck lints - Update CI to use current golangci-lint - Upgrade actions/checkout, actions/setup-go, and golangci/golangci-lint-action
1 parent db42941 commit 49260dc

File tree

7 files changed

+69
-59
lines changed

7 files changed

+69
-59
lines changed

.github/workflows/checks.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ permissions:
1212
env:
1313
CGO_ENABLED: 0
1414
GO_VERSION: stable
15-
GOLANGCI_LINT_VERSION: v1.64.5
15+
GOLANGCI_LINT_VERSION: v2.6.1
1616
SHELLCHECK_SCRIPTS: ./*.sh
1717
jobs:
1818
go-lint-checks:
1919
runs-on: ubuntu-latest
2020
steps:
21-
- uses: actions/checkout@v4
22-
- uses: actions/setup-go@v5
21+
- uses: actions/checkout@v5
22+
- uses: actions/setup-go@v6
2323
with:
2424
go-version: ${{ env.GO_VERSION }}
2525
- name: Run GolangCI-Lint
26-
uses: golangci/golangci-lint-action@v6
26+
uses: golangci/golangci-lint-action@v9
2727
with:
2828
version: ${{ env.GOLANGCI_LINT_VERSION }}
2929
go-mod-checks:
3030
runs-on: ubuntu-latest
3131
steps:
32-
- uses: actions/checkout@v4
33-
- uses: actions/setup-go@v5
32+
- uses: actions/checkout@v5
33+
- uses: actions/setup-go@v6
3434
with:
3535
go-version: ${{ env.GO_VERSION }}
3636
- name: Check if go.mod is tidy

.github/workflows/go-cross.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ jobs:
2525
- windows-latest
2626
steps:
2727
- name: Checkout code
28-
uses: actions/checkout@v4
28+
uses: actions/checkout@v5
2929
- name: Set up Go
30-
uses: actions/setup-go@v5
30+
uses: actions/setup-go@v6
3131
with:
3232
go-version: ${{ matrix.go-version }}
3333
- name: Build the module

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ jobs:
3232
- linux
3333
- windows
3434
steps:
35-
- uses: actions/checkout@v4
36-
- uses: actions/setup-go@v5
35+
- uses: actions/checkout@v5
36+
- uses: actions/setup-go@v6
3737
with:
3838
check-latest: true
3939
go-version-file: go.mod
@@ -62,7 +62,7 @@ jobs:
6262
- pebble
6363
- pebble-challtestsrv
6464
steps:
65-
- uses: actions/checkout@v4
65+
- uses: actions/checkout@v5
6666
- name: Download ${{ matrix.app }} artifacts
6767
uses: actions/download-artifact@v4
6868
with:

.golangci.yaml

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
linters-settings:
2-
gocyclo:
3-
min-complexity: 25
4-
misspell:
5-
locale: "US"
6-
1+
version: "2"
72
linters:
8-
disable-all: false
93
enable:
104
- asasalint
115
- asciicheck
@@ -17,7 +11,6 @@ linters:
1711
- dogsled
1812
- dupword
1913
- durationcheck
20-
- errcheck
2114
- errchkjson
2215
- errorlint
2316
- forcetypeassert
@@ -26,18 +19,12 @@ linters:
2619
- gocognit
2720
- goconst
2821
- gocyclo
29-
- gofmt
30-
- gofumpt
3122
- goheader
32-
- goimports
3323
- gomoddirectives
3424
- gomodguard
3525
- goprintffuncname
36-
- gosimple
37-
- govet
3826
- importas
3927
- inamedparam
40-
- ineffassign
4128
- ireturn
4229
- loggercheck
4330
- makezero
@@ -51,33 +38,55 @@ linters:
5138
- predeclared
5239
- reassign
5340
- revive
54-
- staticcheck
5541
- tagalign
5642
- testableexamples
5743
- testifylint
5844
- thelper
5945
- unconvert
6046
- unparam
61-
- unused
6247
- usestdlibvars
6348
- usetesting
6449
- wastedassign
65-
50+
settings:
51+
gocyclo:
52+
min-complexity: 25
53+
misspell:
54+
locale: US
55+
exclusions:
56+
generated: lax
57+
presets:
58+
- comments
59+
- common-false-positives
60+
- legacy
61+
- std-error-handling
62+
rules:
63+
- path: ca/ca.go
64+
text: type name will be used as ca.CAImpl by other packages, and that stutters; consider calling this Impl
65+
- path: va/va.go
66+
text: type name will be used as va.VAImpl by other packages, and that stutters; consider calling this Impl
67+
- path: wfe/wfe.go
68+
text: if` block ends with a `return` statement, so drop this `else` and outdent its block
69+
- linters:
70+
- goconst
71+
path: va/va.go
72+
text: string `Incorrect validation certificate for %s challenge. ` has \d occurrences, make it a constant
73+
- path: (.+)\.go$
74+
text: fmt.Sprintf can be replaced with string
75+
paths:
76+
- third_party$
77+
- builtin$
78+
- examples$
6679
issues:
67-
exclude-use-default: true
6880
max-issues-per-linter: 0
6981
max-same-issues: 0
70-
# The following excludes are considered false-positives/known-OK.
71-
exclude:
72-
- fmt.Sprintf can be replaced with string
73-
exclude-rules:
74-
- path: ca/ca.go
75-
text: 'type name will be used as ca.CAImpl by other packages, and that stutters; consider calling this Impl'
76-
- path: va/va.go
77-
text: 'type name will be used as va.VAImpl by other packages, and that stutters; consider calling this Impl'
78-
- path: wfe/wfe.go
79-
text: 'if` block ends with a `return` statement, so drop this `else` and outdent its block'
80-
- path: va/va.go
81-
linters:
82-
- goconst
83-
text: 'string `Incorrect validation certificate for %s challenge. ` has \d occurrences, make it a constant'
82+
formatters:
83+
enable:
84+
- gofmt
85+
- gofumpt
86+
- goimports
87+
exclusions:
88+
generated: lax
89+
paths:
90+
- third_party$
91+
- builtin$
92+
- examples$

cmd/pebble-challtestsrv/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func mustParsePOST(ob interface{}, request *http.Request) error {
1717
}
1818

1919
if string(jsonBody) == "" {
20-
return errors.New("Expected JSON POST body, was empty")
20+
return errors.New("expected JSON POST body, was empty")
2121
}
2222

2323
return json.Unmarshal(jsonBody, ob)

cmd/pebble-challtestsrv/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type managementServer struct {
2828
}
2929

3030
func (srv *managementServer) Run() {
31-
srv.log.Printf("Starting management server on %s", srv.Server.Addr)
31+
srv.log.Printf("Starting management server on %s", srv.Addr)
3232
// Start the HTTP server in its own dedicated Go routine
3333
go func() {
3434
err := srv.ListenAndServe()

wfe/wfe.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,17 +1847,17 @@ func (wfe *WebFrontEndImpl) orderForDisplay(
18471847
// identifiers and authorizations slices and not the slices or the mutations
18481848
// below could mutate the order in the database, causing data races.
18491849
result := acme.Order{
1850-
Status: order.Order.Status,
1851-
Error: order.Order.Error,
1852-
Expires: order.Order.Expires,
1853-
Identifiers: slices.Clone(order.Order.Identifiers),
1854-
Profile: order.Order.Profile,
1855-
Finalize: order.Order.Finalize,
1856-
NotBefore: order.Order.NotBefore,
1857-
NotAfter: order.Order.NotAfter,
1858-
Authorizations: slices.Clone(order.Order.Authorizations),
1859-
Certificate: order.Order.Certificate,
1860-
Replaces: order.Order.Replaces,
1850+
Status: order.Status,
1851+
Error: order.Error,
1852+
Expires: order.Expires,
1853+
Identifiers: slices.Clone(order.Identifiers),
1854+
Profile: order.Profile,
1855+
Finalize: order.Finalize,
1856+
NotBefore: order.NotBefore,
1857+
NotAfter: order.NotAfter,
1858+
Authorizations: slices.Clone(order.Authorizations),
1859+
Certificate: order.Certificate,
1860+
Replaces: order.Replaces,
18611861
}
18621862

18631863
// Randomize the order of the order authorization URLs as well as the order's
@@ -2892,11 +2892,12 @@ func (wfe *WebFrontEndImpl) RevokeCert(
28922892

28932893
// Handle the revocation request according to how it is authenticated, or if
28942894
// the authentication type is unknown, error immediately
2895-
if authType == embeddedKeyID {
2895+
switch authType {
2896+
case embeddedKeyID:
28962897
prob = wfe.revokeCertByKeyID(parsedJWS, request)
2897-
} else if authType == embeddedJWK {
2898+
case embeddedJWK:
28982899
prob = wfe.revokeCertByJWK(parsedJWS, request)
2899-
} else {
2900+
default:
29002901
prob = acme.MalformedProblem("Malformed JWS, no KeyID or embedded JWK")
29012902
}
29022903
if prob != nil {

0 commit comments

Comments
 (0)