add the exhaustive linter, replace panics by return values in logging stringers #2729
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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).