mirror of
https://github.com/scratchfoundation/golangci-lint.git
synced 2025-08-28 22:28:43 -04:00
add support for exclude rules
This commit is contained in:
parent
b607ea387e
commit
a3a04552bb
4 changed files with 139 additions and 2 deletions
34
pkg/result/processors/exclude_rules_test.go
Normal file
34
pkg/result/processors/exclude_rules_test.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package processors
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/golangci/golangci-lint/pkg/result"
|
||||
)
|
||||
|
||||
func TestExcludeRules(t *testing.T) {
|
||||
p := NewExcludeRules([]ExcludeRule{
|
||||
{
|
||||
Text: "^exclude$",
|
||||
},
|
||||
})
|
||||
texts := []string{"excLude", "1", "", "exclud", "notexclude"}
|
||||
var issues []result.Issue
|
||||
for _, t := range texts {
|
||||
issues = append(issues, newTextIssue(t))
|
||||
}
|
||||
|
||||
processedIssues := process(t, p, issues...)
|
||||
assert.Len(t, processedIssues, len(issues)-1)
|
||||
|
||||
var processedTexts []string
|
||||
for _, i := range processedIssues {
|
||||
processedTexts = append(processedTexts, i.Text)
|
||||
}
|
||||
assert.Equal(t, texts[1:], processedTexts)
|
||||
t.Run("Empty", func(t *testing.T) {
|
||||
processAssertSame(t, NewExcludeRules(nil), newTextIssue("test"))
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue