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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user