1
0
mirror of https://github.com/mgechev/revive.git synced 2025-11-29 22:28:23 +02:00

refactor: enable few linters in golangci-lint config (#1580)

This commit is contained in:
Oleksandr Redko
2025-11-15 20:50:52 +02:00
committed by GitHub
parent d81298b0ce
commit 5dc6ed197b
23 changed files with 50 additions and 41 deletions

View File

@@ -3,6 +3,7 @@ package rule
import (
"fmt"
"regexp"
"strings"
"github.com/mgechev/revive/lint"
)
@@ -55,7 +56,7 @@ func (r *FileHeaderRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure
if g == nil {
return failure
}
comment := ""
var comment strings.Builder
for _, c := range g.List {
text := c.Text
if multiRegexp.MatchString(text) {
@@ -63,7 +64,7 @@ func (r *FileHeaderRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure
} else if singleRegexp.MatchString(text) {
text = text[2:]
}
comment += text
comment.WriteString(text)
}
regex, err := regexp.Compile(r.header)
@@ -71,7 +72,7 @@ func (r *FileHeaderRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure
return newInternalFailureError(err)
}
if !regex.MatchString(comment) {
if !regex.MatchString(comment.String()) {
return failure
}
return nil