-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
add the exhaustive linter, replace panics by return values in logging stringers #2729
Conversation
959155c
to
7406eaa
Compare
Codecov Report
@@ Coverage Diff @@
## master #2729 +/- ##
==========================================
+ Coverage 85.92% 85.93% +0.01%
==========================================
Files 133 133
Lines 12075 12087 +12
==========================================
+ Hits 10375 10386 +11
- Misses 1365 1366 +1
Partials 335 335
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GH is showing tons of lint errors. Do you want to fix those now or later?
861cd0a
to
dea4a34
Compare
dea4a34
to
e8fedd2
Compare
e8fedd2
to
8417b67
Compare
Depends on #2728.
A while back, @lanzafame suggested to replace the
panic
s in theStringer
s of logging types by "unknown" return values. Of course, he was right with that suggestion. Logging is not a good enough reason to panic.Turns out that there's an even better solution for this: the exhaustive linter, which even is part of the golangci-lint suite. This linter allows us to check that
switch
statement for enum types cover all values defined for that enum.There are a few cases in our code where we deliberately don't do an exhaustive check, and I've added a
nolint:exhaustive
statement there. This is fine, at least it forces us to be explicit about this. In fact, activating this linter actually caught a bug in the packet packer (#2728).