mirror of
https://github.com/coredns/coredns.git
synced 2025-11-06 03:56:24 -05:00
chore(lint): update to golangci-lint v2.6.0 (#7645)
Update to the latest golangci-lint version and use built-in modernize linter, instead of a custom CI step. Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
This commit is contained in:
4
.github/workflows/golangci-lint.yml
vendored
4
.github/workflows/golangci-lint.yml
vendored
@@ -20,6 +20,4 @@ jobs:
|
|||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
|
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
|
||||||
with:
|
with:
|
||||||
version: v2.5.0
|
version: v2.6.0
|
||||||
- name: modernize
|
|
||||||
run: go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@2e31135b736b96cd609904370c71563ce5447826 -diff -test ./... # v0.20.0
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ linters:
|
|||||||
- govet
|
- govet
|
||||||
- ineffassign
|
- ineffassign
|
||||||
- intrange
|
- intrange
|
||||||
|
- modernize
|
||||||
- nakedret
|
- nakedret
|
||||||
- nolintlint
|
- nolintlint
|
||||||
- perfsprint
|
- perfsprint
|
||||||
@@ -42,6 +43,9 @@ linters:
|
|||||||
govet:
|
govet:
|
||||||
enable:
|
enable:
|
||||||
- nilness
|
- nilness
|
||||||
|
modernize:
|
||||||
|
disable:
|
||||||
|
- reflecttypefor
|
||||||
perfsprint:
|
perfsprint:
|
||||||
error-format: false
|
error-format: false
|
||||||
revive:
|
revive:
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ func (r *cnameTargetRule) getFromAndToTarget(inputCName string) (from string, to
|
|||||||
return inputCName, r.paramToTarget + after
|
return inputCName, r.paramToTarget + after
|
||||||
}
|
}
|
||||||
case SuffixMatch:
|
case SuffixMatch:
|
||||||
if strings.HasSuffix(inputCName, r.paramFromTarget) {
|
if before, ok := strings.CutSuffix(inputCName, r.paramFromTarget); ok {
|
||||||
return inputCName, strings.TrimSuffix(inputCName, r.paramFromTarget) + r.paramToTarget
|
return inputCName, before + r.paramToTarget
|
||||||
}
|
}
|
||||||
case SubstringMatch:
|
case SubstringMatch:
|
||||||
if strings.Contains(inputCName, r.paramFromTarget) {
|
if strings.Contains(inputCName, r.paramFromTarget) {
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ func newSuffixStringRewriter(orig, replacement string) stringRewriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *suffixStringRewriter) rewriteString(src string) string {
|
func (r *suffixStringRewriter) rewriteString(src string) string {
|
||||||
if strings.HasSuffix(src, r.suffix) {
|
if before, ok := strings.CutSuffix(src, r.suffix); ok {
|
||||||
return strings.TrimSuffix(src, r.suffix) + r.replacement
|
return before + r.replacement
|
||||||
}
|
}
|
||||||
return src
|
return src
|
||||||
}
|
}
|
||||||
@@ -234,8 +234,8 @@ func newSuffixNameRule(nextAction string, auto bool, suffix, replacement string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rule *suffixNameRule) Rewrite(ctx context.Context, state request.Request) (ResponseRules, Result) {
|
func (rule *suffixNameRule) Rewrite(ctx context.Context, state request.Request) (ResponseRules, Result) {
|
||||||
if strings.HasSuffix(state.Name(), rule.suffix) {
|
if before, ok := strings.CutSuffix(state.Name(), rule.suffix); ok {
|
||||||
state.Req.Question[0].Name = strings.TrimSuffix(state.Name(), rule.suffix) + rule.replacement
|
state.Req.Question[0].Name = before + rule.replacement
|
||||||
return rule.responseRuleFor(state)
|
return rule.responseRuleFor(state)
|
||||||
}
|
}
|
||||||
return nil, RewriteIgnored
|
return nil, RewriteIgnored
|
||||||
|
|||||||
Reference in New Issue
Block a user