ireturn: update tests & docs (#3800)

This commit is contained in:
Oleg Butuzov 2023-04-25 14:57:32 +03:00 committed by GitHub
parent cbc3a0c70e
commit 66ac4b5570
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 2 deletions

View File

@ -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.

View File

@ -0,0 +1,4 @@
linters-settings:
ireturn:
reject:
- generic

View 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
}

View File

@ -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 (