tinkerbell / lint-install

Consistently install reasonable linter rules for open-source projects
Apache License 2.0
6 stars 7 forks source link

Disable errorf option for errorlint. #41

Closed chrisdoherty4 closed 2 years ago

chrisdoherty4 commented 2 years ago

The errorf option forces developers to expose errors as part of their package APIs. This has the effect of forcing any use of a third party or other package's errors to become part of a package API.

Errors are part of [a] package API. If [an author is] forced to use %w it means [they're] forced to make all errors, whether [generated in the new code or not], part of the package API. That should really be a conscious decision by the author, not mandated by a linter.

Hyrum's law comes into play because consumers become dependent on that error type and that was never intended making things harder to change in the future.

- https://github.com/tinkerbell/hegel/pull/82#discussion_r852453070

displague commented 2 years ago

Additional context here: https://github.com/tinkerbell/hegel/pull/82#discussion_r852267922

mmlb commented 2 years ago

Aww looks like I lost my comment here... I was initially against this change mostly because I took issue with the statement:

The errorf option forces developers to expose errors as part of their package APIs.

As I didn't see that to be necessarily true. But after going back and re-reading the relevant go blog post its explicitly called out that the use of %w is so that code can parse the error. If code was not meant to parse the error then %v should be used. I think that matches up with the statement and so am now on board with this.

chrisdoherty4 commented 2 years ago

@mmlb Are you able to merge this?