2018-07-07 10:40:02 +02:00
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-08-11 10:35:08 +05:00
|
|
|
"github.com/mgechev/revive/lint"
|
2018-07-07 10:40:02 +02:00
|
|
|
"github.com/mgechev/revive/rule"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestUnusedParam(t *testing.T) {
|
2024-11-11 13:39:10 +02:00
|
|
|
testRule(t, "unused_param", &rule.UnusedParamRule{})
|
2024-12-04 06:55:19 +02:00
|
|
|
testRule(t, "unused_param", &rule.UnusedParamRule{}, &lint.RuleConfig{Arguments: []any{}})
|
|
|
|
testRule(t, "unused_param", &rule.UnusedParamRule{}, &lint.RuleConfig{Arguments: []any{
|
|
|
|
map[string]any{"a": "^xxx"},
|
|
|
|
}})
|
2024-11-11 13:39:10 +02:00
|
|
|
testRule(t, "unused_param_custom_regex", &rule.UnusedParamRule{}, &lint.RuleConfig{Arguments: []any{
|
2023-09-24 08:44:02 +02:00
|
|
|
map[string]any{"allowRegex": "^xxx"},
|
2023-08-11 10:35:08 +05:00
|
|
|
}})
|
2018-07-07 10:40:02 +02:00
|
|
|
}
|
2019-04-21 19:13:03 +02:00
|
|
|
|
|
|
|
func BenchmarkUnusedParam(b *testing.B) {
|
|
|
|
var t *testing.T
|
|
|
|
for i := 0; i <= b.N; i++ {
|
2024-11-11 13:39:10 +02:00
|
|
|
testRule(t, "unused_param", &rule.UnusedParamRule{})
|
2019-04-21 19:13:03 +02:00
|
|
|
}
|
|
|
|
}
|