mirror of
https://github.com/mgechev/revive.git
synced 2025-11-23 22:04:49 +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>
28 lines
696 B
Go
28 lines
696 B
Go
package test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/mgechev/revive/lint"
|
|
"github.com/mgechev/revive/rule"
|
|
)
|
|
|
|
func TestDefer(t *testing.T) {
|
|
testRule(t, "defer", &rule.DeferRule{})
|
|
}
|
|
|
|
func TestDeferLoopDisabled(t *testing.T) {
|
|
testRule(t, "defer_loop_disabled", &rule.DeferRule{}, &lint.RuleConfig{
|
|
Arguments: []any{[]any{"return", "recover", "callChain", "methodCall"}},
|
|
})
|
|
testRule(t, "defer_loop_disabled", &rule.DeferRule{}, &lint.RuleConfig{
|
|
Arguments: []any{[]any{"return", "recover", "call-chain", "method-call"}},
|
|
})
|
|
}
|
|
|
|
func TestDeferOthersDisabled(t *testing.T) {
|
|
testRule(t, "defer_only_loop_enabled", &rule.DeferRule{}, &lint.RuleConfig{
|
|
Arguments: []any{[]any{"loop"}},
|
|
})
|
|
}
|