-
Notifications
You must be signed in to change notification settings - Fork 11
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
request a new option enforce-enum-types #65
Comments
@nishanths hi, what do you think about the feature? If it is ok, I'd like to help with this feature. |
I'm +1 for this. Does the following description match what you are thinking?
Please feel free to send a pull request! |
Could we discuss the following portion from the issue description more?
Were you suggesting that we might need special (i.e. non-straightforward) handling for the intersection of
The first two combinations |
Thanks for your reply! Yes, I think the behaviors of four combinations you list are just as same as I understand. I will start to work on this and send a pr ASAP. |
Consider also the approach used in https://github.com/GaijinEntertainment/go-exhaustruct via regexes to allow covering entire packages or subdirectories. There's a lot of analogies between this analyzer and that one. |
In project opentelemetry-collector-contrib, we want to use exhaustive linter to confirm the way of using
go.opentelemetry.io/collector/pdata/pmetric.MetricType
.related issue:
open-telemetry/opentelemetry-collector-contrib#7532
open-telemetry/opentelemetry-collector-contrib#23242
However in this project, there will be a lot of code provided by third-party vendors. These third-party code may come with their own enum types that may violate the exhaustive lint requirements. But in reality, these third-party enum types are not something we are concerned about.
What we want to achieve is to only check the
go.opentelemetry.io/collector/pdata/pmetric.MetricType
enum type while ignoring all other enum types. But for now, there is no option we can achieve, so we have to use--explicit-exhaustive-switch
option, manually pick out all places in code wherepmetric
enum type is used, then add//exhaustive:enforce
comment. This method is very prone to omissions and errors since it is manual.So I wonder if we can support another option like
enforce-enum-types
, which is just likeignore-enum-types
, but the behavior is opposite. And maybe this option should come up withexplicit-exhaustive-switch
. Whenexplicit-exhaustive-switch
is enabled and an enum type A is specified inenforce-enum-types
, then all switch or map using enum type A and the switch with//exhaustive:enforce
will be checked.The text was updated successfully, but these errors were encountered: