Skip to content

Commit

Permalink
Use the same test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
denisvmedia committed Sep 23, 2023
1 parent 0f78543 commit b98d59e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
4 changes: 2 additions & 2 deletions testdata/enforce-slice-style-any.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ func somefn2() {
type SliceSlice Slice

func somefn3() {
m2 := make(SliceSlice, 0)
m3 := make(SliceSlice, 0, 0)
m0 := make(SliceSlice, 10)
m1 := make(SliceSlice, 0, 10)
m2 := make(SliceSlice, 0)
m3 := make(SliceSlice, 0, 0)
m4 := SliceSlice{}
m5 := SliceSlice{"v1", "v2"}

Expand Down
4 changes: 2 additions & 2 deletions testdata/enforce-slice-style-literal.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ func somefn2() {
type SliceSlice Slice

func somefn3() {
m2 := make(SliceSlice, 0) // MATCH /use []type{} instead of make([]type, 0) (or declare nil slice)/
m3 := make(SliceSlice, 0, 0) // MATCH /use []type{} instead of make([]type, 0) (or declare nil slice)/
m0 := make(SliceSlice, 10)
m1 := make(SliceSlice, 0, 10)
m2 := make(SliceSlice, 0) // MATCH /use []type{} instead of make([]type, 0) (or declare nil slice)/
m3 := make(SliceSlice, 0, 0) // MATCH /use []type{} instead of make([]type, 0) (or declare nil slice)/
m4 := SliceSlice{}
m5 := SliceSlice{"v1", "v2"}

Expand Down
27 changes: 17 additions & 10 deletions testdata/enforce-slice-style-make.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ func somefn() {
m0 := make([]string, 10)
m1 := make([]string, 0, 10)
m2 := make([]string, 0)
m3 := []string{} // MATCH /use make([]type) instead of []type{} (or declare nil slice)/
m4 := []string{"v1", "v2"}
m5 := [8]string{}
m6 := [...]string{}
m3 := make([]string, 0, 0)
m4 := []string{} // MATCH /use make([]type) instead of []type{} (or declare nil slice)/
m5 := []string{"v1", "v2"}
m6 := [8]string{}
m7 := [...]string{}

_ = m0
_ = m1
Expand All @@ -16,6 +17,7 @@ func somefn() {
_ = m4
_ = m5
_ = m6
_ = m7
}

type Slice []string
Expand All @@ -24,14 +26,16 @@ func somefn2() {
m0 := make(Slice, 10)
m1 := make(Slice, 0, 10)
m2 := make(Slice, 0)
m3 := Slice{} // MATCH /use make([]type) instead of []type{} (or declare nil slice)/
m4 := Slice{"v1", "v2"}
m3 := make(Slice, 0, 0)
m4 := Slice{} // MATCH /use make([]type) instead of []type{} (or declare nil slice)/
m5 := Slice{"v1", "v2"}

_ = m0
_ = m1
_ = m2
_ = m3
_ = m4
_ = m5
}

type SliceSlice Slice
Expand All @@ -40,23 +44,26 @@ func somefn3() {
m0 := make(SliceSlice, 10)
m1 := make(SliceSlice, 0, 10)
m2 := make(SliceSlice, 0)
m3 := SliceSlice{} // MATCH /use make([]type) instead of []type{} (or declare nil slice)/
m4 := SliceSlice{"v1", "v2"}
m3 := make(SliceSlice, 0, 0)
m4 := SliceSlice{} // MATCH /use make([]type) instead of []type{} (or declare nil slice)/
m5 := SliceSlice{"v1", "v2"}

_ = m0
_ = m1
_ = m2
_ = m3
_ = m4
_ = m5
}

func somefn4() {
m1 := [][]string{} // MATCH /use make([]type) instead of []type{} (or declare nil slice)/
m1["el0"] = make([]string, 10)
m1["el1"] = make([]string, 0, 10)
m1["el2"] = make([]string, 0)
m1["el3"] = []string{} // MATCH /use make([]type) instead of []type{} (or declare nil slice)/
m1["el4"] = []string{"v1", "v2"}
m1["el3"] = make([]string, 0, 0)
m1["el4"] = []string{} // MATCH /use make([]type) instead of []type{} (or declare nil slice)/
m1["el5"] = []string{"v1", "v2"}

_ = m1
}

0 comments on commit b98d59e

Please sign in to comment.