Skip to content

Commit b2faa73

Browse files
authored
chore: update linter (#2507)
1 parent fcc64f0 commit b2faa73

File tree

5 files changed

+76
-78
lines changed

5 files changed

+76
-78
lines changed

.github/workflows/pr.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
env:
1515
GO_VERSION: stable
16-
GOLANGCI_LINT_VERSION: v2.0.1
16+
GOLANGCI_LINT_VERSION: v2.1.1
1717
HUGO_VERSION: 0.131.0
1818
CGO_ENABLED: 0
1919
LEGO_E2E_TESTS: CI

.golangci.yml

+63-65
Original file line numberDiff line numberDiff line change
@@ -152,114 +152,112 @@ linters:
152152
- go-require
153153
usetesting:
154154
os-setenv: false # we already have a test "framework" to handle env vars
155+
funcorder:
156+
struct-method: false
155157

156158
exclusions:
157159
warn-unused: true
158160
presets:
159161
- comments
160162
- std-error-handling
161163
rules:
162-
- linters:
164+
- path: (.+)_test.go
165+
linters:
163166
- funlen
164167
- goconst
165168
- maintidx
166-
path: (.+)_test.go
167-
- linters:
168-
- errcheck
169-
path: (.+)_test.go
169+
- path: (.+)_test.go
170170
text: Error return value of `fmt.Fprintln` is not checked
171-
- linters:
172-
- gochecknoglobals
173-
path: certcrypto/crypto.go
171+
linters:
172+
- errcheck
173+
- path: certcrypto/crypto.go
174174
text: (tlsFeatureExtensionOID|ocspMustStapleFeature) is a global variable
175-
- linters:
175+
linters:
176176
- gochecknoglobals
177-
path: challenge/dns01/nameserver.go
177+
- path: challenge/dns01/nameserver.go
178178
text: (defaultNameservers|recursiveNameservers|fqdnSoaCache|muFqdnSoaCache) is a global variable
179-
- linters:
179+
linters:
180180
- gochecknoglobals
181-
path: challenge/dns01/nameserver_.+.go
181+
- path: challenge/dns01/nameserver_.+.go
182182
text: dnsTimeout is a global variable
183-
- linters:
183+
linters:
184184
- gochecknoglobals
185-
path: challenge/dns01/nameserver_test.go
185+
- path: challenge/dns01/nameserver_test.go
186186
text: findXByFqdnTestCases is a global variable
187-
- linters:
188-
- goconst
189-
path: challenge/http01/domain_matcher.go
190-
text: string `Host` has \d occurrences, make it a constant
191-
- linters:
192-
- gocyclo
193-
path: challenge/http01/domain_matcher.go
187+
linters:
188+
- gochecknoglobals
189+
- path: challenge/http01/domain_matcher.go
194190
text: cyclomatic complexity \d+ of func `parseForwardedHeader` is high
195-
- linters:
196-
- funlen
197-
path: challenge/http01/domain_matcher.go
191+
linters:
192+
- gocyclo
193+
- path: challenge/http01/domain_matcher.go
198194
text: Function 'parseForwardedHeader' has too many statements
199-
- linters:
200-
- gochecknoglobals
201-
path: challenge/tlsalpn01/tls_alpn_challenge.go
195+
linters:
196+
- funlen
197+
- path: challenge/tlsalpn01/tls_alpn_challenge.go
202198
text: idPeAcmeIdentifierV1 is a global variable
203-
- linters:
199+
linters:
204200
- gochecknoglobals
205-
path: log/logger.go
201+
- path: log/logger.go
206202
text: Logger is a global variable
207-
- linters:
203+
linters:
208204
- gochecknoglobals
209-
path: e2e/(dnschallenge/)?[\d\w]+_test.go
205+
- path: e2e/(dnschallenge/)?[\d\w]+_test.go
210206
text: load is a global variable
211-
- linters:
207+
linters:
212208
- gochecknoglobals
213-
path: providers/dns/([\d\w]+/)*[\d\w]+_test.go
209+
- path: providers/dns/([\d\w]+/)*[\d\w]+_test.go
214210
text: envTest is a global variable
215-
- linters:
211+
linters:
216212
- gochecknoglobals
217-
path: providers/http/([\d\w]+/)*[\d\w]+_test.go
213+
- path: providers/http/([\d\w]+/)*[\d\w]+_test.go
218214
text: envTest is a global variable
219-
- linters:
215+
linters:
220216
- gochecknoglobals
221-
path: providers/dns/namecheap/namecheap_test.go
217+
- path: providers/dns/namecheap/namecheap_test.go
222218
text: testCases is a global variable
223-
- linters:
219+
linters:
224220
- gochecknoglobals
225-
path: providers/dns/acmedns/mock_test.go
221+
- path: providers/dns/acmedns/mock_test.go
226222
text: egTestAccount is a global variable
227-
- linters:
223+
linters:
228224
- gochecknoglobals
229-
path: providers/http/memcached/memcached_test.go
225+
- path: providers/http/memcached/memcached_test.go
230226
text: memcachedHosts is a global variable
231-
- linters:
232-
- misspell
233-
path: providers/dns/checkdomain/internal/types.go
227+
linters:
228+
- gochecknoglobals
229+
- path: providers/dns/checkdomain/internal/types.go
234230
text: '`payed` is a misspelling of `paid`'
235-
- linters:
231+
linters:
232+
- misspell
233+
- path: platform/tester/env_test.go
234+
linters:
236235
- thelper
237-
path: platform/tester/env_test.go
238-
- linters:
239-
- staticcheck
240-
path: providers/dns/oraclecloud/oraclecloud_test.go
236+
- path: providers/dns/oraclecloud/oraclecloud_test.go
241237
text: 'SA1019: x509.EncryptPEMBlock has been deprecated since Go 1.16'
242-
- linters:
243-
- gochecknoglobals
244-
path: providers/dns/sakuracloud/wrapper.go
238+
linters:
239+
- staticcheck
240+
- path: providers/dns/sakuracloud/wrapper.go
245241
text: mu is a global variable
246-
- linters:
247-
- gocyclo
248-
path: cmd/cmd_renew.go
242+
linters:
243+
- gochecknoglobals
244+
- path: cmd/cmd_renew.go
249245
text: cyclomatic complexity \d+ of func `(renewForDomains|renewForCSR)` is high
250-
- linters:
251-
- funlen
252-
path: cmd/cmd_renew.go
253-
text: Function 'renewForDomains' has too many statements
254-
- linters:
246+
linters:
255247
- gocyclo
256-
path: providers/dns/cpanel/cpanel.go
248+
- path: cmd/cmd_renew.go
249+
text: Function 'renewForDomains' has too many statements
250+
linters:
251+
- funlen
252+
- path: providers/dns/cpanel/cpanel.go
257253
text: cyclomatic complexity 13 of func `\(\*DNSProvider\)\.CleanUp` is high
258-
- linters:
259-
- staticcheck
260-
# Those elements have been replaced by non-exposed structures.
261-
path: providers/dns/linode/linode_test.go
254+
linters:
255+
- gocyclo
256+
# Those elements have been replaced by non-exposed structures.
257+
- path: providers/dns/linode/linode_test.go
262258
text: 'SA1019: linodego\.(DomainsPagedResponse|DomainRecordsPagedResponse) is deprecated'
259+
linters:
260+
- staticcheck
263261

264262
issues:
265263
max-issues-per-linter: 0

providers/dns/acmedns/acmedns.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,19 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
115115

116116
// NewDNSProviderClient creates an ACME-DNS DNSProvider with the given acmeDNSClient and [goacmedns.Storage].
117117
// Deprecated: use [NewDNSProviderConfig] instead.
118-
func NewDNSProviderClient(client acmeDNSClient, storage goacmedns.Storage) (*DNSProvider, error) {
118+
func NewDNSProviderClient(client acmeDNSClient, store goacmedns.Storage) (*DNSProvider, error) {
119119
if client == nil {
120120
return nil, errors.New("acme-dns: Client must be not nil")
121121
}
122122

123-
if storage == nil {
123+
if store == nil {
124124
return nil, errors.New("acme-dns: Storage must be not nil")
125125
}
126126

127127
return &DNSProvider{
128128
config: NewDefaultConfig(),
129129
client: client,
130-
storage: storage,
130+
storage: store,
131131
}, nil
132132
}
133133

providers/dns/googledomains/googledomains.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ func NewDefaultConfig() *Config {
4646
}
4747
}
4848

49+
type DNSProvider struct {
50+
config *Config
51+
acmedns *acmedns.Service
52+
}
53+
4954
// NewDNSProvider returns the Google Domains DNS provider with a default configuration.
5055
func NewDNSProvider() (*DNSProvider, error) {
5156
values, err := env.Get(EnvAccessToken)
@@ -80,11 +85,6 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
8085
}, nil
8186
}
8287

83-
type DNSProvider struct {
84-
config *Config
85-
acmedns *acmedns.Service
86-
}
87-
8888
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
8989
zone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain))
9090
if err != nil {

providers/dns/ovh/ovh.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ type Config struct {
8383
HTTPClient *http.Client
8484
}
8585

86-
func (c *Config) hasAppKeyAuth() bool {
87-
return c.ApplicationKey != "" || c.ApplicationSecret != "" || c.ConsumerKey != ""
88-
}
89-
9086
// NewDefaultConfig returns a default configuration for the DNSProvider.
9187
func NewDefaultConfig() *Config {
9288
return &Config{
@@ -99,6 +95,10 @@ func NewDefaultConfig() *Config {
9995
}
10096
}
10197

98+
func (c *Config) hasAppKeyAuth() bool {
99+
return c.ApplicationKey != "" || c.ApplicationSecret != "" || c.ConsumerKey != ""
100+
}
101+
102102
// DNSProvider implements the challenge.Provider interface.
103103
type DNSProvider struct {
104104
config *Config

0 commit comments

Comments
 (0)