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

adds defer rule

This commit is contained in:
chavacava
2020-05-24 20:49:49 +02:00
committed by Minko Gechev
parent 2976b46f8d
commit ad3100c9ec
8 changed files with 269 additions and 0 deletions

25
test/defer_test.go Normal file
View File

@@ -0,0 +1,25 @@
package test
import (
"testing"
"github.com/mgechev/revive/lint"
"github.com/mgechev/revive/rule"
)
// Defer 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: []interface{}{[]interface{}{"return", "recover", "call-chain", "method-call"}},
})
}
func TestDeferOthersDisabled(t *testing.T) {
testRule(t, "defer-only-loop-enabled", &rule.DeferRule{}, &lint.RuleConfig{
Arguments: []interface{}{[]interface{}{"loop"}},
})
}