-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DefaultExcludePatterns should only be used for specified linter (#1494)
Co-authored-by: zhangyunhao <[email protected]>
- Loading branch information
1 parent
df2e9e2
commit 9948153
Showing
7 changed files
with
90 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetExcludePatterns(t *testing.T) { | ||
assert.Equal(t, GetExcludePatterns(nil), DefaultExcludePatterns) | ||
|
||
include := make([]string, 2) | ||
include[0], include[1] = DefaultExcludePatterns[0].ID, DefaultExcludePatterns[1].ID | ||
|
||
exclude := GetExcludePatterns(include) | ||
assert.Equal(t, len(exclude), len(DefaultExcludePatterns)-len(include)) | ||
|
||
for _, p := range exclude { | ||
// Not in include. | ||
for _, i := range include { | ||
if i == p.ID { | ||
t.Fatalf("%s can't appear inside include.", p.ID) | ||
} | ||
} | ||
// Must in DefaultExcludePatterns. | ||
var inDefaultExc bool | ||
for _, i := range DefaultExcludePatterns { | ||
if i == p { | ||
inDefaultExc = true | ||
break | ||
} | ||
} | ||
assert.True(t, inDefaultExc, fmt.Sprintf("%s must appear inside DefaultExcludePatterns.", p.ID)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
issues: | ||
include: | ||
- EXC0011 # include issues about comments from `stylecheck` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//args: -Estylecheck,golint | ||
//config_path: testdata/configs/default_exclude.yml | ||
|
||
/*Package testdata ...*/ | ||
package testdata | ||
|
||
// InvalidFuncComment, both golint and stylecheck will complain about this, // ERROR `ST1020: comment on exported function ExportedFunc1 should be of the form "ExportedFunc1 ..."` | ||
// if include EXC0011, only the warning from golint will be ignored. | ||
// And only the warning from stylecheck will start with "ST1020". | ||
func ExportedFunc1() { | ||
} | ||
|
||
// InvalidFuncComment // ERROR `ST1020: comment on exported function ExportedFunc2 should be of the form "ExportedFunc2 ..."` | ||
// nolint:golint | ||
func ExportedFunc2() { | ||
} | ||
|
||
// nolint:stylecheck | ||
func IgnoreAll() { | ||
} |