chore: update linter (#1852)
This commit is contained in:
parent
052adf246e
commit
1b98b20058
5 changed files with 183 additions and 211 deletions
2
.github/workflows/pr.yml
vendored
2
.github/workflows/pr.yml
vendored
|
@ -13,7 +13,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GO_VERSION: '1.20'
|
||||
GOLANGCI_LINT_VERSION: v1.51.1
|
||||
GOLANGCI_LINT_VERSION: v1.51.2
|
||||
HUGO_VERSION: 0.54.0
|
||||
CGO_ENABLED: 0
|
||||
LEGO_E2E_TESTS: CI
|
||||
|
|
210
.golangci.toml
210
.golangci.toml
|
@ -1,210 +0,0 @@
|
|||
[run]
|
||||
timeout = "7m"
|
||||
skip-files = []
|
||||
|
||||
[linters-settings]
|
||||
|
||||
[linters-settings.govet]
|
||||
check-shadowing = true
|
||||
|
||||
[linters-settings.gocyclo]
|
||||
min-complexity = 12.0
|
||||
|
||||
[linters-settings.maligned]
|
||||
suggest-new = true
|
||||
|
||||
[linters-settings.goconst]
|
||||
min-len = 3.0
|
||||
min-occurrences = 3.0
|
||||
|
||||
[linters-settings.funlen]
|
||||
lines = -1
|
||||
statements = 50
|
||||
|
||||
[linters-settings.misspell]
|
||||
locale = "US"
|
||||
ignore-words = ["internetbs"]
|
||||
|
||||
[linters-settings.depguard]
|
||||
list-type = "denylist"
|
||||
include-go-root = false
|
||||
packages = ["github.com/pkg/errors"]
|
||||
|
||||
[linters-settings.godox]
|
||||
keywords = ["FIXME"]
|
||||
|
||||
[linters-settings.gocritic]
|
||||
enabled-tags = ["diagnostic", "style", "performance"]
|
||||
disabled-checks= [
|
||||
"paramTypeCombine", # already handle by gofumpt.extra-rules
|
||||
"whyNoLint", # already handle by nonolint
|
||||
"unnamedResult",
|
||||
"hugeParam",
|
||||
"sloppyReassign",
|
||||
"rangeValCopy",
|
||||
"octalLiteral",
|
||||
"ptrToRefParam",
|
||||
"appendAssign",
|
||||
"ruleguard",
|
||||
"httpNoBody",
|
||||
"exposedSyncMutex",
|
||||
]
|
||||
|
||||
[linters]
|
||||
enable-all = true
|
||||
disable = [
|
||||
"deadcode", # deprecated
|
||||
"exhaustivestruct", # deprecated
|
||||
"golint", # deprecated
|
||||
"ifshort", # deprecated
|
||||
"interfacer", # deprecated
|
||||
"maligned", # deprecated
|
||||
"nosnakecase", # deprecated
|
||||
"scopelint", # deprecated
|
||||
"structcheck", # deprecated
|
||||
"varcheck", # deprecated
|
||||
"cyclop", # duplicate of gocyclo
|
||||
"sqlclosecheck", # not relevant (SQL)
|
||||
"rowserrcheck", # not relevant (SQL)
|
||||
"execinquery", # not relevant (SQL)
|
||||
"lll",
|
||||
"gosec",
|
||||
"dupl", # not relevant
|
||||
"prealloc", # too many false-positive
|
||||
"bodyclose", # too many false-positive
|
||||
"gomnd",
|
||||
"testpackage", # not relevant
|
||||
"tparallel", # not relevant
|
||||
"paralleltest", # not relevant
|
||||
"nestif", # too many false-positive
|
||||
"wrapcheck",
|
||||
"goerr113", # not relevant
|
||||
"nlreturn", # not relevant
|
||||
"wsl", # not relevant
|
||||
"exhaustive", # not relevant
|
||||
"exhaustruct", # not relevant
|
||||
"makezero", # not relevant
|
||||
"forbidigo", # not relevant
|
||||
"varnamelen", # not relevant
|
||||
"nilnil", # not relevant
|
||||
"ireturn", # not relevant
|
||||
"contextcheck", # too many false-positive
|
||||
"tenv", # we already have a test "framework" to handle env vars
|
||||
"noctx",
|
||||
"forcetypeassert",
|
||||
"tagliatelle",
|
||||
"errname",
|
||||
"errchkjson",
|
||||
"nonamedreturns",
|
||||
"musttag", # false-positive https://github.com/junk1tm/musttag/issues/17
|
||||
]
|
||||
|
||||
[issues]
|
||||
exclude-use-default = false
|
||||
max-per-linter = 0
|
||||
max-same-issues = 0
|
||||
exclude = [
|
||||
"Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked",
|
||||
"exported (type|method|function) (.+) should have comment or be unexported",
|
||||
"ST1000: at least one file in a package should have a package comment",
|
||||
"package-comments: should have a package comment",
|
||||
]
|
||||
[[issues.exclude-rules]]
|
||||
path = "(.+)_test.go"
|
||||
linters = ["funlen", "goconst", "maintidx"]
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/dns_providers.go"
|
||||
linters = ["gocyclo"]
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/gcloud/googlecloud_test.go"
|
||||
text = "string `(lego\\.wtf|manhattan)` has (\\d+) occurrences, make it a constant"
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/zoneee/zoneee_test.go"
|
||||
text = "string `(bar|foo)` has (\\d+) occurrences, make it a constant"
|
||||
[[issues.exclude-rules]]
|
||||
path = "certcrypto/crypto.go"
|
||||
text = "(tlsFeatureExtensionOID|ocspMustStapleFeature) is a global variable"
|
||||
[[issues.exclude-rules]]
|
||||
path = "challenge/dns01/nameserver.go"
|
||||
text = "(defaultNameservers|recursiveNameservers|fqdnSoaCache|muFqdnSoaCache) is a global variable"
|
||||
[[issues.exclude-rules]]
|
||||
path = "challenge/dns01/nameserver_.+.go"
|
||||
text = "dnsTimeout is a global variable"
|
||||
[[issues.exclude-rules]]
|
||||
path = "challenge/dns01/nameserver_test.go"
|
||||
text = "findXByFqdnTestCases is a global variable"
|
||||
[[issues.exclude-rules]]
|
||||
path = "challenge/http01/domain_matcher.go"
|
||||
text = "string `Host` has \\d occurrences, make it a constant"
|
||||
[[issues.exclude-rules]]
|
||||
path = "challenge/http01/domain_matcher.go"
|
||||
text = "cyclomatic complexity \\d+ of func `parseForwardedHeader` is high"
|
||||
[[issues.exclude-rules]]
|
||||
path = "challenge/http01/domain_matcher.go"
|
||||
text = "Function 'parseForwardedHeader' has too many statements"
|
||||
[[issues.exclude-rules]]
|
||||
path = "challenge/tlsalpn01/tls_alpn_challenge.go"
|
||||
text = "idPeAcmeIdentifierV1 is a global variable"
|
||||
[[issues.exclude-rules]]
|
||||
path = "log/logger.go"
|
||||
text = "Logger is a global variable"
|
||||
[[issues.exclude-rules]]
|
||||
path = "e2e/(dnschallenge/)?[\\d\\w]+_test.go"
|
||||
text = "load is a global variable"
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/([\\d\\w]+/)*[\\d\\w]+_test.go"
|
||||
text = "envTest is a global variable"
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/namecheap/namecheap_test.go"
|
||||
text = "testCases is a global variable"
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/acmedns/acmedns_test.go"
|
||||
text = "egTestAccount is a global variable"
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/http/memcached/memcached_test.go"
|
||||
text = "memcachedHosts is a global variable"
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/sakuracloud/client_test.go"
|
||||
text = "cyclomatic complexity 13 of func `(TestDNSProvider_cleanupTXTRecord_concurrent|TestDNSProvider_addTXTRecord_concurrent)` is high"
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/dns_providers.go"
|
||||
text = "Function 'NewDNSChallengeProviderByName' has too many statements"
|
||||
[[issues.exclude-rules]]
|
||||
path = "cmd/flags.go"
|
||||
text = "Function 'CreateFlags' is too long"
|
||||
[[issues.exclude-rules]]
|
||||
path = "certificate/certificates.go"
|
||||
text = "Function 'GetOCSP' is too long"
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/otc/client.go"
|
||||
text = "Function 'loginRequest' is too long"
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/gandi/gandi.go"
|
||||
text = "Function 'Present' is too long"
|
||||
[[issues.exclude-rules]]
|
||||
path = "cmd/zz_gen_cmd_dnshelp.go"
|
||||
linters = ["gocyclo", "funlen"]
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/checkdomain/client.go"
|
||||
text = "`payed` is a misspelling of `paid`"
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/namecheap/namecheap_test.go"
|
||||
text = "cognitive complexity (\\d+) of func `TestDNSProvider_getHosts` is high"
|
||||
[[issues.exclude-rules]]
|
||||
path = "platform/tester/env_test.go"
|
||||
linters = ["thelper"]
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/oraclecloud/oraclecloud_test.go"
|
||||
text = "SA1019: x509.EncryptPEMBlock has been deprecated since Go 1.16"
|
||||
[[issues.exclude-rules]]
|
||||
path = "challenge/http01/domain_matcher.go"
|
||||
text = "yodaStyleExpr"
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/dns_providers.go"
|
||||
text = "Function name: NewDNSChallengeProviderByName,"
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/sakuracloud/client.go"
|
||||
text = "mu is a global variable"
|
||||
[[issues.exclude-rules]]
|
||||
path = "providers/dns/hosttech/internal/client_test.go"
|
||||
text = "Duplicate words \\(0\\) found"
|
180
.golangci.yml
Normal file
180
.golangci.yml
Normal file
|
@ -0,0 +1,180 @@
|
|||
run:
|
||||
timeout: 7m
|
||||
skip-files: []
|
||||
|
||||
linters-settings:
|
||||
govet:
|
||||
check-shadowing: true
|
||||
gocyclo:
|
||||
min-complexity: 12
|
||||
maligned:
|
||||
suggest-new: true
|
||||
goconst:
|
||||
min-len: 3
|
||||
min-occurrences: 3
|
||||
funlen:
|
||||
lines: -1
|
||||
statements: 50
|
||||
misspell:
|
||||
locale: US
|
||||
ignore-words:
|
||||
- internetbs
|
||||
depguard:
|
||||
list-type: denylist
|
||||
include-go-root: false
|
||||
packages:
|
||||
- github.com/pkg/errors
|
||||
- github.com/instana/testify
|
||||
godox:
|
||||
keywords:
|
||||
- FIXME
|
||||
gocritic:
|
||||
enabled-tags:
|
||||
- diagnostic
|
||||
- style
|
||||
- performance
|
||||
disabled-checks:
|
||||
- paramTypeCombine # already handle by gofumpt.extra-rules
|
||||
- whyNoLint # already handle by nonolint
|
||||
- unnamedResult
|
||||
- hugeParam
|
||||
- sloppyReassign
|
||||
- rangeValCopy
|
||||
- octalLiteral
|
||||
- ptrToRefParam
|
||||
- appendAssign
|
||||
- ruleguard
|
||||
- httpNoBody
|
||||
- exposedSyncMutex
|
||||
|
||||
linters:
|
||||
enable-all: true
|
||||
disable:
|
||||
- deadcode # deprecated
|
||||
- exhaustivestruct # deprecated
|
||||
- golint # deprecated
|
||||
- ifshort # deprecated
|
||||
- interfacer # deprecated
|
||||
- maligned # deprecated
|
||||
- nosnakecase # deprecated
|
||||
- scopelint # deprecated
|
||||
- structcheck # deprecated
|
||||
- varcheck # deprecated
|
||||
- cyclop # duplicate of gocyclo
|
||||
- sqlclosecheck # not relevant (SQL)
|
||||
- rowserrcheck # not relevant (SQL)
|
||||
- execinquery # not relevant (SQL)
|
||||
- lll
|
||||
- gosec
|
||||
- dupl # not relevant
|
||||
- prealloc # too many false-positive
|
||||
- bodyclose # too many false-positive
|
||||
- gomnd
|
||||
- testpackage # not relevant
|
||||
- tparallel # not relevant
|
||||
- paralleltest # not relevant
|
||||
- nestif # too many false-positive
|
||||
- wrapcheck
|
||||
- goerr113 # not relevant
|
||||
- nlreturn # not relevant
|
||||
- wsl # not relevant
|
||||
- exhaustive # not relevant
|
||||
- exhaustruct # not relevant
|
||||
- makezero # not relevant
|
||||
- forbidigo
|
||||
- varnamelen # not relevant
|
||||
- nilnil # not relevant
|
||||
- ireturn # not relevant
|
||||
- contextcheck # too many false-positive
|
||||
- tenv # we already have a test "framework" to handle env vars
|
||||
- noctx
|
||||
- forcetypeassert
|
||||
- tagliatelle
|
||||
- errname
|
||||
- errchkjson
|
||||
- nonamedreturns
|
||||
- musttag # false-positive https://github.com/junk1tm/musttag/issues/17
|
||||
|
||||
issues:
|
||||
exclude-use-default: false
|
||||
max-per-linter: 0
|
||||
max-same-issues: 0
|
||||
exclude:
|
||||
- 'Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked'
|
||||
- 'exported (type|method|function) (.+) should have comment or be unexported'
|
||||
- 'ST1000: at least one file in a package should have a package comment'
|
||||
- 'package-comments: should have a package comment'
|
||||
exclude-rules:
|
||||
- path: (.+)_test.go
|
||||
linters:
|
||||
- funlen
|
||||
- goconst
|
||||
- maintidx
|
||||
- path: providers/dns/dns_providers.go
|
||||
linters:
|
||||
- gocyclo
|
||||
- path: providers/dns/gcloud/googlecloud_test.go
|
||||
text: 'string `(lego\.wtf|manhattan)` has (\d+) occurrences, make it a constant'
|
||||
- path: providers/dns/zoneee/zoneee_test.go
|
||||
text: 'string `(bar|foo)` has (\d+) occurrences, make it a constant'
|
||||
- path: certcrypto/crypto.go
|
||||
text: '(tlsFeatureExtensionOID|ocspMustStapleFeature) is a global variable'
|
||||
- path: challenge/dns01/nameserver.go
|
||||
text: '(defaultNameservers|recursiveNameservers|fqdnSoaCache|muFqdnSoaCache) is a global variable'
|
||||
- path: challenge/dns01/nameserver_.+.go
|
||||
text: 'dnsTimeout is a global variable'
|
||||
- path: challenge/dns01/nameserver_test.go
|
||||
text: 'findXByFqdnTestCases is a global variable'
|
||||
- path: challenge/http01/domain_matcher.go
|
||||
text: 'string `Host` has \d occurrences, make it a constant'
|
||||
- path: challenge/http01/domain_matcher.go
|
||||
text: 'cyclomatic complexity \d+ of func `parseForwardedHeader` is high'
|
||||
- path: challenge/http01/domain_matcher.go
|
||||
text: "Function 'parseForwardedHeader' has too many statements"
|
||||
- path: challenge/tlsalpn01/tls_alpn_challenge.go
|
||||
text: 'idPeAcmeIdentifierV1 is a global variable'
|
||||
- path: log/logger.go
|
||||
text: 'Logger is a global variable'
|
||||
- path: 'e2e/(dnschallenge/)?[\d\w]+_test.go'
|
||||
text: load is a global variable
|
||||
- path: 'providers/dns/([\d\w]+/)*[\d\w]+_test.go'
|
||||
text: 'envTest is a global variable'
|
||||
- path: providers/dns/namecheap/namecheap_test.go
|
||||
text: 'testCases is a global variable'
|
||||
- path: providers/dns/acmedns/acmedns_test.go
|
||||
text: 'egTestAccount is a global variable'
|
||||
- path: providers/http/memcached/memcached_test.go
|
||||
text: 'memcachedHosts is a global variable'
|
||||
- path: providers/dns/sakuracloud/client_test.go
|
||||
text: 'cyclomatic complexity 13 of func `(TestDNSProvider_cleanupTXTRecord_concurrent|TestDNSProvider_addTXTRecord_concurrent)` is high'
|
||||
- path: providers/dns/dns_providers.go
|
||||
text: "Function 'NewDNSChallengeProviderByName' has too many statements"
|
||||
- path: cmd/flags.go
|
||||
text: "Function 'CreateFlags' is too long"
|
||||
- path: certificate/certificates.go
|
||||
text: "Function 'GetOCSP' is too long"
|
||||
- path: providers/dns/otc/client.go
|
||||
text: "Function 'loginRequest' is too long"
|
||||
- path: providers/dns/gandi/gandi.go
|
||||
text: "Function 'Present' is too long"
|
||||
- path: cmd/zz_gen_cmd_dnshelp.go
|
||||
linters:
|
||||
- gocyclo
|
||||
- funlen
|
||||
- path: providers/dns/checkdomain/client.go
|
||||
text: '`payed` is a misspelling of `paid`'
|
||||
- path: providers/dns/namecheap/namecheap_test.go
|
||||
text: 'cognitive complexity (\d+) of func `TestDNSProvider_getHosts` is high'
|
||||
- path: platform/tester/env_test.go
|
||||
linters:
|
||||
- thelper
|
||||
- path: providers/dns/oraclecloud/oraclecloud_test.go
|
||||
text: 'SA1019: x509.EncryptPEMBlock has been deprecated since Go 1.16'
|
||||
- path: challenge/http01/domain_matcher.go
|
||||
text: 'yodaStyleExpr'
|
||||
- path: providers/dns/dns_providers.go
|
||||
text: 'Function name: NewDNSChallengeProviderByName,'
|
||||
- path: providers/dns/sakuracloud/client.go
|
||||
text: 'mu is a global variable'
|
||||
- path: providers/dns/hosttech/internal/client_test.go
|
||||
text: 'Duplicate words \(0\) found'
|
|
@ -266,6 +266,7 @@ func (c *Client) doRequest(payload, responseData interface{}) error {
|
|||
if responseData != nil {
|
||||
err = json.Unmarshal(respMsg.ResponseData, responseData)
|
||||
if err != nil {
|
||||
//nolint:errorlint // in this context respMsg is not an error.
|
||||
return fmt.Errorf("%v: unmarshaling %T error: %w: %s",
|
||||
respMsg, responseData, err, string(respMsg.ResponseData))
|
||||
}
|
||||
|
|
|
@ -124,6 +124,7 @@ func (c *Client) DeleteRecord(domain string, data Record) (*Message, error) {
|
|||
var msg Message
|
||||
err = json.Unmarshal(raw, &msg)
|
||||
if err != nil {
|
||||
//nolint:errorlint // in this context msg is not an error, and we just get the type.
|
||||
return nil, fmt.Errorf("unmarshaling %T error: %w: %s", msg, err, string(raw))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue