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

Consider enabling tomarrell/wrapcheck #534

Open
atc0005 opened this issue Mar 3, 2022 · 0 comments
Open

Consider enabling tomarrell/wrapcheck #534

atc0005 opened this issue Mar 3, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request linting question Further information is requested unstable
Milestone

Comments

@atc0005
Copy link
Owner

atc0005 commented Mar 3, 2022

Overview

Description from the project README:

A simple Go linter to check that errors from external packages are wrapped during return to help identify the error source during debugging.

From the linked blog post:

Hence, it would be helpful to have a simple set of rules to follow for when errors should be wrapped. This is by no means an exhaustive set, however should cover the majority of common cases within most programs.

  1. When you have additional context, which you think would be useful to give to the developer reading the log. This is important, as rules are not infallible.
  2. Errors returned from another package. Wrapping these helps identify the entry point of the error into your program.
  3. Errors returned by interface methods. Interfaces may be implemented by a separate package, therefore wrapping the errors here with context may be valuable.

...

Wrapcheck is a new linter for Go which I built in order to maintain consistency across a codebase with regards to point (1) and (2).

This is in contrast to the goerr113 linter which enforces these linting rules:

  1. error values should not be compared directly but with errors.Is() method.
  2. error should not be created dynamically from scratch but by the wrapping the static (package-level) error.

NOTE: This linter is also included in the golangci-lint project.

References

@atc0005 atc0005 added enhancement New feature or request question Further information is requested linting labels Mar 3, 2022
@atc0005 atc0005 added this to the Future milestone Mar 3, 2022
@atc0005 atc0005 self-assigned this Mar 3, 2022
@atc0005 atc0005 modified the milestones: Future, Next Release Apr 29, 2022
@atc0005 atc0005 pinned this issue Apr 29, 2022
@atc0005 atc0005 modified the milestones: Next Release, Future May 10, 2022
@atc0005 atc0005 unpinned this issue Jun 19, 2022
@atc0005 atc0005 pinned this issue Jun 19, 2022
@atc0005 atc0005 modified the milestones: Future, Next Release Aug 9, 2022
@atc0005 atc0005 unpinned this issue Aug 9, 2022
@atc0005 atc0005 modified the milestones: v0.6.22, Next Release Aug 15, 2022
@atc0005 atc0005 modified the milestones: Next Release, Future Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request linting question Further information is requested unstable
Projects
None yet
Development

No branches or pull requests

1 participant