Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

New check: Warn when errors.Is() arguments swapped #1530

Open
mholt opened this issue Apr 26, 2024 · 0 comments
Open

New check: Warn when errors.Is() arguments swapped #1530

mholt opened this issue Apr 26, 2024 · 0 comments

Comments

@mholt
Copy link

mholt commented Apr 26, 2024

It's almost never right to write errors.Is(fs.ErrNotExist, err), but I still do it sometimes to much head-scratching 馃槄 It should be errors.Is(err, fs.ErrNotExist).

Would love it if there's way to warn when the first argument is an exported error value, especially one in another package... catch it much sooner.

Thanks for the consideration!

Also, many thanks for Staticcheck. It is a huge timesaver.

@mholt mholt added the needs-triage Newly filed issue that needs triage label Apr 26, 2024
@dominikh dominikh added new-check and removed needs-triage Newly filed issue that needs triage labels Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants