1
0
mirror of https://github.com/mgechev/revive.git synced 2025-10-30 23:37:49 +02:00

refactor: remove useless failure slice declaration (#1141)

Co-authored-by: chavacava <salvador.cavadini@gmail.com>
This commit is contained in:
chavacava
2024-11-20 20:41:07 +01:00
committed by GitHub
parent 7f769f8c16
commit 303ae4a4be

View File

@@ -13,8 +13,6 @@ type RedundantBuildTagRule struct{}
// `//go:build` comments are automatically added by gofmt when Go 1.17+ is used.
// See https://pkg.go.dev/cmd/go#hdr-Build_constraints
func (*RedundantBuildTagRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure {
var failures []lint.Failure
for _, group := range file.AST.Comments {
hasGoBuild := false
for _, comment := range group.List {
@@ -22,19 +20,19 @@ func (*RedundantBuildTagRule) Apply(file *lint.File, arguments lint.Arguments) [
hasGoBuild = true
continue
}
if hasGoBuild && strings.HasPrefix(comment.Text, "// +build ") {
failures = append(failures, lint.Failure{
return []lint.Failure{{
Category: "style",
Confidence: 1,
Node: comment,
Failure: `The build tag "// +build" is redundant since Go 1.17 and can be removed`,
})
return failures
}}
}
}
}
return failures
return []lint.Failure{}
}
// Name returns the rule name.