Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
demoManito committed Apr 12, 2023
1 parent de1cf23 commit 0d855d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions rules/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ func emptyError(m dsl.Matcher) {
//doc:after var x []int
//doc:tags style
func emptySlice(m dsl.Matcher) {
m.Match(`var $name = make([]$type, 0)`,
`$name := []$type{}`, `$name = []$type{}`,
`$name := make([]$type, 0, 0)`, `$name := make([]$type, 0)`).
m.Match(`var $name = make([]$type, 0)`, `$name := []$type{}`, `$name := make([]$type, 0, 0)`, `$name := make([]$type, 0)`).
Report(`nil slice is the preferred style`).
Suggest(`var $name []$type`)
}
6 changes: 3 additions & 3 deletions rules/testdata/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func emptyError() {
}

func emptySlice() {
x := []int{} // want `\Qnil slice is the preferred style, should be: var x []int`
x = []int{} // want `\Qnil slice is the preferred style, should be: var x []int`
fmt.Println(x)
x := []int{} // want `\Qnil slice is the preferred style, should be: var x []int`
a := make([]int, 0, 0) // want `\Qnil slice is the preferred style, should be: var a []int`
fmt.Println(x, a)
}

0 comments on commit 0d855d2

Please sign in to comment.