ireturn: update tests & docs (#3800)
This commit is contained in:
parent
cbc3a0c70e
commit
66ac4b5570
@ -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.
|
||||
|
4
test/testdata/configs/ireturn_reject_generics.yml
vendored
Normal file
4
test/testdata/configs/ireturn_reject_generics.yml
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
linters-settings:
|
||||
ireturn:
|
||||
reject:
|
||||
- generic
|
25
test/testdata/ireturn_reject_generics.go
vendored
Normal file
25
test/testdata/ireturn_reject_generics.go
vendored
Normal file
@ -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
test/testdata/ireturn_reject_stdlib.go
vendored
2
test/testdata/ireturn_reject_stdlib.go
vendored
@ -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 (
|
||||
|
Loading…
x
Reference in New Issue
Block a user