-
Notifications
You must be signed in to change notification settings - Fork 285
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 WithRelatedCheckConfigs
option to check additional check configs for unused plugins warning
#3550
Conversation
…figs for unused plugins warning
The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).
|
// The caller can provider additional check configs to check if the plugin has rules configured. | ||
// If the plugin has rules configured in any of the additional check configs provided, then | ||
// we don't warn. |
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.
The case above (In client.Lint and client.Breaking, we only have the Lint or Breaking config
) could probably be removed now to say related configs are provided for validation and remove the heuristic workaround based on other rule types.
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.
So this is one I was kinda hoping to get opinions on. Currently, I am only providing the respective other check configs (e.g. other lint configs for lint, other breaking configs for breaking), but yes, we could provide both instead, and that would allow us to remove this clause and rely solely on the related check configs. I like that idea, but I wanted to get others' opinions on this.
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.
I thought a little bit more about this, and the goal of this is to provide users with a clear warning for whenever a plugin does not have any configured rules and/or categories. And so I think it actually doesn't make sense to rely on the heuristic, it seems we are doing this because RulesConfig
always only ever applies to a single RuleType
:
buf/private/bufpkg/bufcheck/rules_config.go
Line 126 in b4d7836
ruleType check.RuleType, |
However, at the time of the validation, we have access to all rules, and so we can check all related check configs, agnostic to rule type, which would allow us to surface a much clearer warning to users without relying on a heuristic.
So I've pushed up an update which removes that heuristic and instead sends all related check configs and checks them for the warning.
WithAdditionalCheckConfigs
option to check additional check configs for unused plugins warningWithRelatedCheckConfigs
option to check additional check configs for unused plugins warning
7df5950
to
e5d360e
Compare
return nil, err | ||
} | ||
allCategoryIDToRuleIDs := getCategoryIDToRuleIDs(allRuleIDToCategoryIDs) | ||
for _, checkConfig := range relatedCheckConfigs { |
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.
It looks like if you specify the WithRelatedCheckConfigs option, these CheckConfigs are not additionally checked, rather these CheckConfigs are the only CheckConfigs that are checked, and the original CheckConfigs (?) from allRules are not checked. Am I wrong/does this make sense? Make sure it is additional.
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.
Yep! On lines 294-305, we are still checking the original configurations, we are just checking the additional rules in lieu of checking whether the plugin has rules from other rules types.
We check for unused plugins when running
Lint
,Breaking
, andConfiguredRules
. However, this is basedon the provided
CheckConfig
, and does not account forconfigurations outside of the current check. This results in a
confusing unused plugin warning for users who may not have
configured rules and/or categories configured for all modules
in their workspace.
This PR introduces a
WithRelatedCheckConfigs
, that allowsus to provide additional check configs to check plugins against.
It also allows us to no longer rely on the heuristic to ignore plugins
with multiple rule types -- we can provide all related check configs
and check against those.