Skip to content

Commit

Permalink
ireturn: update tests & docs (#3800)
Browse files Browse the repository at this point in the history
  • Loading branch information
butuzov committed Apr 25, 2023
1 parent cbc3a0c commit 66ac4b5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .golangci.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1159,13 +1159,14 @@ linters-settings:
max: 5

ireturn:
# ireturn allows using `allow` and `reject` settings at the same time.
# ireturn does not allow using `allow` and `reject` settings at the same time.
# Both settings are lists of the keywords and regular expressions matched to interface or package names.
# keywords:
# - `empty` for `interface{}`
# - `error` for errors
# - `stdlib` for standard library
# - `anon` for anonymous interfaces
# - `generic` for generic interfaces added in go 1.18

# By default, it allows using errors, empty interfaces, anonymous interfaces,
# and interfaces provided by the standard library.
Expand Down
4 changes: 4 additions & 0 deletions test/testdata/configs/ireturn_reject_generics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
linters-settings:
ireturn:
reject:
- generic
25 changes: 25 additions & 0 deletions test/testdata/ireturn_reject_generics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//golangcitest:args -Eireturn
//golangcitest:config_path testdata/configs/ireturn_reject_generics.yml
package testdata

import (
"bytes"
"io"
)

func NewWriter() io.Writer {
var buf bytes.Buffer
return &buf
}

func TestError() error {
return nil
}

func Get[K comparable, V int64 | float64](m map[K]V) V { // want `Get returns generic interface \(V\)`
var s V
for _, v := range m {
s += v
}
return s
}
2 changes: 1 addition & 1 deletion test/testdata/ireturn_reject_stdlib.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//golangcitest:args -Eireturn
//golangcitest:config_path testdata/configs/ireturn_stdlib_reject.yml
//golangcitest:config_path testdata/configs/ireturn_reject_stdlib.yml
package testdata

import (
Expand Down

0 comments on commit 66ac4b5

Please sign in to comment.