-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement whilelist for switch #54
Labels
Comments
Another example: func SwitchIoEOF(r io.Reader) {
var buf [4096]byte
_, err := r.Read(buf[:])
switch err {
case nil:
return
case io.EOF:
return
}
fmt.Println(err)
} |
kolyshkin
added a commit
to kolyshkin/sys
that referenced
this issue
Aug 25, 2023
golangci-lint v1.54.2 comes with errorlint v1.4.4, which contains the fix [1] whitelisting all errno comparisons for errors coming from x/sys/unix. Remove the annotation that is no longer needed. Unfortunately, switch on a bare unix error (in mountinfo) still needs to be annotated (see [2]). [1] polyfloyd/go-errorlint#47 [2] polyfloyd/go-errorlint#54 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
kolyshkin
added a commit
to kolyshkin/sys
that referenced
this issue
Aug 25, 2023
golangci-lint v1.54.2 comes with errorlint v1.4.4, which contains the fix [1] whitelisting all errno comparisons for errors coming from x/sys/unix. Remove the annotation that is no longer needed. Unfortunately, switch on a bare unix error (in mountinfo) still needs to be annotated (see [2]). [1] polyfloyd/go-errorlint#47 [2] polyfloyd/go-errorlint#54 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
kolyshkin
added a commit
to kolyshkin/sys
that referenced
this issue
Aug 25, 2023
golangci-lint v1.54.2 comes with errorlint v1.4.4, which contains the fix [1] whitelisting all errno comparisons for errors coming from x/sys/unix. Remove the annotation that is no longer needed. Unfortunately, switch on a bare unix error (in mountinfo) still needs to be annotated (see [2]). [1] polyfloyd/go-errorlint#47 [2] polyfloyd/go-errorlint#54 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Yes, that should be a valid comparison. The allowlist must apply to switch statements too |
kolyshkin
added a commit
to kolyshkin/sys
that referenced
this issue
Oct 27, 2023
golangci-lint v1.54.2 comes with errorlint v1.4.4, which contains the fix [1] whitelisting all errno comparisons for errors coming from x/sys/unix. Remove the annotation that is no longer needed. Unfortunately, switch on a bare unix error (in mountinfo) still needs to be annotated (see [2]). [1] polyfloyd/go-errorlint#47 [2] polyfloyd/go-errorlint#54 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Fixed in c0e6cac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following legitimate comparison using switch statement
results in a warning:
Apparently, whitelist of allowed direct comparisons, as implemented in
allowed.go
, is not used when analysing switch statements.The text was updated successfully, but these errors were encountered: