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>
30 lines
903 B
Go
30 lines
903 B
Go
package test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/mgechev/revive/lint"
|
|
"github.com/mgechev/revive/rule"
|
|
)
|
|
|
|
func TestUnusedReceiver(t *testing.T) {
|
|
testRule(t, "unused_receiver", &rule.UnusedReceiverRule{})
|
|
testRule(t, "unused_receiver", &rule.UnusedReceiverRule{}, &lint.RuleConfig{Arguments: []any{}})
|
|
testRule(t, "unused_receiver", &rule.UnusedReceiverRule{}, &lint.RuleConfig{Arguments: []any{
|
|
map[string]any{"a": "^xxx"},
|
|
}})
|
|
testRule(t, "unused_receiver_custom_regex", &rule.UnusedReceiverRule{}, &lint.RuleConfig{Arguments: []any{
|
|
map[string]any{"allowRegex": "^xxx"},
|
|
}})
|
|
testRule(t, "unused_receiver_custom_regex", &rule.UnusedReceiverRule{}, &lint.RuleConfig{Arguments: []any{
|
|
map[string]any{"allow-regex": "^xxx"},
|
|
}})
|
|
}
|
|
|
|
func BenchmarkUnusedReceiver(b *testing.B) {
|
|
var t *testing.T
|
|
for i := 0; i <= b.N; i++ {
|
|
testRule(t, "unused_receiver", &rule.UnusedReceiverRule{})
|
|
}
|
|
}
|