-
-
Notifications
You must be signed in to change notification settings - Fork 224
Result of preprocessors not considerd for exit code #300
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
Comments
🚀 This issue has been resolved in v2.34.0. See Release 2.34.0 for release notes. |
Thanks for taking time to work on this issue. But I think it's still not fixed. The CLI command still returns the wrong exit code if issues are filtered by preprocessors. Because firstly the filter method in cli.ts still references the unprocessed report And secondly the reduce function is using the counters dictionary which I think has to be reevaluated after the preprocessors run? |
I've got a temporary solution, need some more time (plus tests!) for this. For now, the |
Thanks a lot for that workaround! |
This is the workaround that I used. At the end of my preprocessor, I loop over all the issue categories and check if that issue category is filled. If it is empty, I set the counter of that category to 0. Note that you also need to clear the issue categories that you exclude in your knip configuration. For example, I have excluded ...
// Excluded categories need to be cleared. And if there are no issues for a category, set the counter to 0.
options.issues.nsExports = {};
options.issues.types = {};
for (const key in options.issues) {
if (options.issues.hasOwnProperty(key)) {
const element = options.issues[key];
if (Object.keys(element).length === 0) {
options.counters[key] = 0;
}
}
}
return options; |
According to issue #204 the preprocessor api can be used to filter out findings of knip. As far as I understand, the result of the preprocessors are not taken into account for calculating the totalErrorCount which is important for the exit code.
Because you advice to use the preprocessor api for a use case like the one in #204 (filter out findings with complex logic), I think it's a bug that the result of the preprocessors are not taken into account for the exit code.
The text was updated successfully, but these errors were encountered: