mirror of
https://github.com/mgechev/revive.git
synced 2025-05-19 22:03:20 +02:00
* rule: tests for Configure with named options; fix errors * rule: refactor and add tests for ifelse rules * rule: allow lowercased and kebab-cased options * test: update integration tests with lowercased params * docs: update rules descriptions * rule: simplify Configure implementation with one option * gofmt and fix lint * review: add isRuleOption, update grammar in doc, simplify regex Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com> --------- Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com>
34 lines
945 B
Go
34 lines
945 B
Go
package test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/mgechev/revive/lint"
|
|
"github.com/mgechev/revive/rule"
|
|
)
|
|
|
|
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: []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",
|
|
}},
|
|
})
|
|
testRule(t, "add_constant", &rule.AddConstantRule{}, &lint.RuleConfig{
|
|
Arguments: []any{map[string]any{
|
|
"max-lit-count": "2",
|
|
"allow-strs": `""`,
|
|
"allow-ints": "0,1,2",
|
|
"allow-floats": "0.0,1.0",
|
|
"ignore-funcs": `os\.(CreateFile|WriteFile|Chmod|FindProcess),\.Println,ignoredFunc,\.Info`,
|
|
}},
|
|
})
|
|
}
|