1
0
mirror of https://github.com/mgechev/revive.git synced 2025-07-13 01:00:17 +02:00

Add new rule

This commit is contained in:
mgechev
2018-02-02 13:32:03 -05:00
parent 837a85713b
commit 2ff1cccfd2
3 changed files with 90 additions and 3 deletions

View File

@ -56,7 +56,7 @@ var rules = []lint.Rule{
&rule.ContextArgumentsRule{},
}
func TestVarDeclaration(t *testing.T) {
func TestCyclomatic(t *testing.T) {
testRule(t, "cyclomatic", &rule.CyclomaticRule{}, &lint.RuleConfig{
Arguments: []interface{}{int64(1)},
})
@ -65,6 +65,12 @@ func TestVarDeclaration(t *testing.T) {
})
}
func TestMaxPublicStructs(t *testing.T) {
testRule(t, "max-public-structs", &rule.MaxPublicStructsRule{}, &lint.RuleConfig{
Arguments: []interface{}{int64(1)},
})
}
func testRule(t *testing.T, filename string, rule lint.Rule, config ...*lint.RuleConfig) {
baseDir := "../fixtures/"
filename = filename + ".go"
@ -94,8 +100,9 @@ func TestAll(t *testing.T) {
baseDir := "../fixtures/"
ignoreFiles := map[string]bool{
"cyclomatic.go": true,
"cyclomatic-2.go": true,
"cyclomatic.go": true,
"cyclomatic-2.go": true,
"max-public-structs.go": true,
}
rx, err := regexp.Compile(*lintMatch)