Repository navigation
fix: Exclude UnmarshalMapstructure by default - #59
Closed
fedorkanin wants to merge 1 commit into
Closed
fedorkanin wants to merge 1 commit into
fedorkanin wants to merge 1 commit into
Conversation
mapstructure's Unmarshaler, used by Viper to decode configuration, must use a pointer receiver, the same as the other Unmarshal methods. Value types that implement it were reported as mixed receivers.
Owner
|
Thanks for the PR and the clear explanation. I agree That said, I'm going to decline this. The default exclusions aren't meant to track interfaces from 3rd party libraries. If I add mapstructure, I'd also have to consider every other decoder that defines its own You can exclude it in your own config instead: linters-settings:
recvcheck:
exclusions:
- "*.UnmarshalMapstructure"Thanks again for taking the time on this. |
Author
|
Makes sense! Thanks for taking a look |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add
UnmarshalMapstructureto the default exclusions.go-viper/mapstructure defines the
Unmarshalerinterface.It is used by Viper, a popular configuration library, to decode config values into custom types.
Like the other
Unmarshal*methods,UnmarshalMapstructuremust use a pointer receiver because it writes to its receiver.Value types that implement it, such as enums decoded from config strings, often keep value receivers for their other methods (
String,MarshalText, etc.).These types are currently reported as mixed receivers, which is a false positive for the same reason as #17.