1
0
mirror of https://github.com/mgechev/revive.git synced 2025-11-23 22:04:49 +02:00

refactor: reduce control nesting in AddConstantRule.configure (#1128)

This commit is contained in:
Oleksandr Redko
2024-11-18 15:38:56 +02:00
committed by GitHub
parent 655e6060b2
commit d81fc8fab3
3 changed files with 77 additions and 64 deletions

View File

@@ -7,16 +7,18 @@ import (
"github.com/mgechev/revive/rule"
)
func TestAddConstant(t *testing.T) {
args := []any{map[string]any{
"maxLitCount": "2",
"allowStrs": "\"\"",
"allowInts": "0,1,2",
"allowFloats": "0.0,1.0",
"ignoreFuncs": "os\\.(CreateFile|WriteFile|Chmod|FindProcess),\\.Println,ignoredFunc,\\.Info",
}}
func TestAddConstantWithDefaultArguments(t *testing.T) {
testRule(t, "add_constant_default", &rule.AddConstantRule{}, &lint.RuleConfig{})
}
func TestAddConstantWithArguments(t *testing.T) {
testRule(t, "add_constant", &rule.AddConstantRule{}, &lint.RuleConfig{
Arguments: args,
Arguments: []any{map[string]any{
"maxLitCount": "2",
"allowStrs": "\"\"",
"allowInts": "0,1,2",
"allowFloats": "0.0,1.0",
"ignoreFuncs": "os\\.(CreateFile|WriteFile|Chmod|FindProcess),\\.Println,ignoredFunc,\\.Info",
}},
})
}