mirror of
https://github.com/mgechev/revive.git
synced 2024-11-24 08:32:22 +02:00
17a0393326
* enforce-slice-style: Support nil declaration enforcement Add support for enforcing nil slice declarations as recommended by both the Go Code Review and Uber style guides. This initial version is quite strict in that it also prevents using empty literal and make-style slices in struct assignments and as function arguments. * Add more tests * docs
31 lines
751 B
Go
31 lines
751 B
Go
package test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/mgechev/revive/lint"
|
|
"github.com/mgechev/revive/rule"
|
|
)
|
|
|
|
func TestEnforceSliceStyle_any(t *testing.T) {
|
|
testRule(t, "enforce-slice-style-any", &rule.EnforceSliceStyleRule{})
|
|
}
|
|
|
|
func TestEnforceSliceStyle_make(t *testing.T) {
|
|
testRule(t, "enforce-slice-style-make", &rule.EnforceSliceStyleRule{}, &lint.RuleConfig{
|
|
Arguments: []any{"make"},
|
|
})
|
|
}
|
|
|
|
func TestEnforceSliceStyle_literal(t *testing.T) {
|
|
testRule(t, "enforce-slice-style-literal", &rule.EnforceSliceStyleRule{}, &lint.RuleConfig{
|
|
Arguments: []any{"literal"},
|
|
})
|
|
}
|
|
|
|
func TestEnforceSliceStyle_nil(t *testing.T) {
|
|
testRule(t, "enforce-slice-style-nil", &rule.EnforceSliceStyleRule{}, &lint.RuleConfig{
|
|
Arguments: []any{"nil"},
|
|
})
|
|
}
|