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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove revive:unhandled-error - errcheck is more flexible #13008

Merged
merged 2 commits into from
Apr 3, 2023
Merged

chore: Remove revive:unhandled-error - errcheck is more flexible #13008

merged 2 commits into from
Apr 3, 2023

Conversation

zak-pawel
Copy link
Collaborator

It doesn't make sense to support two linters for checking if returned error is handled.

errcheck is able to find more problems, and have default exclusion list (which can be extended in .golangci.yml)
https://github.com/kisielk/errcheck/blob/master/errcheck/excludes.go#L11

		// bytes
		"(*bytes.Buffer).Write",
		"(*bytes.Buffer).WriteByte",
		"(*bytes.Buffer).WriteRune",
		"(*bytes.Buffer).WriteString",

		// fmt
		"fmt.Errorf",
		"fmt.Print",
		"fmt.Printf",
		"fmt.Println",
		"fmt.Fprint(*bytes.Buffer)",
		"fmt.Fprintf(*bytes.Buffer)",
		"fmt.Fprintln(*bytes.Buffer)",
		"fmt.Fprint(*strings.Builder)",
		"fmt.Fprintf(*strings.Builder)",
		"fmt.Fprintln(*strings.Builder)",
		"fmt.Fprint(os.Stderr)",
		"fmt.Fprintf(os.Stderr)",
		"fmt.Fprintln(os.Stderr)",

		// io
		"(*io.PipeReader).CloseWithError",
		"(*io.PipeWriter).CloseWithError",

		// math/rand
		"math/rand.Read",
		"(*math/rand.Rand).Read",

		// strings
		"(*strings.Builder).Write",
		"(*strings.Builder).WriteByte",
		"(*strings.Builder).WriteRune",
		"(*strings.Builder).WriteString",

		// hash
		"(hash.Hash).Write",

revive allows to exclude only functions. errcheck supports also methods, so doesn't need a lot of repeating //nolint's in code.

@Hipska
Copy link
Contributor

Hipska commented Apr 3, 2023

Maybe add a "closes #12892"?

@Hipska Hipska added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Apr 3, 2023
@zak-pawel
Copy link
Collaborator Author

Maybe add a "closes #12892"?

Only when we agree to not enable gosec:G104 in #12892 ;)

@srebhan
Copy link
Member

srebhan commented Apr 3, 2023

I think we do agree to not enable G104 for the reason you outlined, don't we @powersj?

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks for cleaning up @zak-pawel.
Additionally to these we might also want to cleanup all _, _ = xyz.Write... calls as they are also a product of these checks. You can find them with grep -nr '_, _ = (\w\+\.)\+Write' * ...

@zak-pawel
Copy link
Collaborator Author

Additionally to these we might also want to cleanup all _, _ = xyz.Write... calls as they are also a product of these checks. You can find them with grep -nr '_, _ = (\w\+\.)\+Write' * ...

Created new issue for that: #13013

@powersj powersj merged commit c76f319 into influxdata:master Apr 3, 2023
srebhan pushed a commit that referenced this pull request Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore linter ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants