mirror of
https://github.com/mgechev/revive.git
synced 2025-11-27 22:18:41 +02:00
prepareSkips: to resolve regexps in excludes (#1060)
* prepareSkips: to resolve regexps in excludes * prepareSkips: to resolve regexps in excludes * cleanup * errorf: format * doublestar/v4: latest version
This commit is contained in:
committed by
GitHub
parent
fd8d99d716
commit
e8b55f8917
@@ -36,6 +36,43 @@ func TestReviveLint(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestReviveLintExcludeWithRegexp(t *testing.T) {
|
||||
// ARRANGE
|
||||
revive := getMockRevive(t)
|
||||
|
||||
// ACT
|
||||
files := []string{"../testdata/if_return.go"}
|
||||
excludePatterns := []string{"*return*"}
|
||||
packages := []*revivelib.LintPattern{}
|
||||
for _, file := range files {
|
||||
packages = append(packages, revivelib.Include(file))
|
||||
}
|
||||
|
||||
for _, file := range excludePatterns {
|
||||
packages = append(packages, revivelib.Exclude(file))
|
||||
}
|
||||
|
||||
failures, err := revive.Lint(packages...)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// ASSERT
|
||||
failureList := []lint.Failure{}
|
||||
|
||||
for failure := range failures {
|
||||
failureList = append(failureList, failure)
|
||||
}
|
||||
|
||||
const expected = 0
|
||||
|
||||
got := len(failureList)
|
||||
if got != expected {
|
||||
t.Fatalf("Expected failures to have %d failures, but it has %d.", expected, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReviveFormat(t *testing.T) {
|
||||
// ARRANGE
|
||||
revive := getMockRevive(t)
|
||||
|
||||
Reference in New Issue
Block a user