Skip to content
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

CLI: Treat errors below severity threshold as warnings #696

Merged

Conversation

davidperezgar
Copy link
Member

Fixes #691

@davidperezgar davidperezgar linked an issue Oct 3, 2024 that may be closed by this pull request
@davidperezgar davidperezgar self-assigned this Oct 3, 2024
@davidperezgar davidperezgar requested review from mukeshpanchal27 and ernilambar and removed request for mukeshpanchal27 October 3, 2024 20:43
Copy link

github-actions bot commented Oct 3, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: davidperezgar <[email protected]>
Co-authored-by: swissspidy <[email protected]>
Co-authored-by: ernilambar <[email protected]>
Co-authored-by: felixarntz <[email protected]>
Co-authored-by: mukeshpanchal27 <[email protected]>
Co-authored-by: frantorres <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ernilambar
Copy link
Member

Current approach of severity is aligned with the PHPCS which could be considered as an industry standard. I would not want to break that approach and expectation.
IMO, we could add some flags to get the required results with errors converted to warnings.
Anyway lets wait for other opinions also.

@davidperezgar
Copy link
Member Author

davidperezgar commented Oct 4, 2024

Ok @ernilambar I agree with you as you tell that is a industry standard. We all want the same results. Which name of the flag do you recommend? something like --show-error-warning-low-severity ?

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidperezgar I'm not sure I fully understand the problem that this is trying to solve. Is the problem that some $results are removed because of the filtering? That seems reasonable to fix.

However, even with this PR implementation, some results would still be missing, which would be warnings with a lower severity.

I'm not sure that we should "migrate" low-severity errors to warnings. That seems like an odd choice. Would be great to get other people's feedback on this.

@davidperezgar
Copy link
Member Author

davidperezgar commented Oct 4, 2024

Thanks @felixarntz . The thing is that we have errors that could have false positives. That's why we use the severity 7 in plugin submission, so the errors with severity less than 7, won't be a blocker. In our team we try to developers to learn about the errors, and it would be very helpful for the team, show that errors, and they could be a warning. I think is the best scenario.

Otherwise, they would find that issues does not a appear and they could not manage to solve them.

I agree with @ernilambar to use a new flag to do that.

@davidperezgar davidperezgar changed the title Convert errors less severity to warnings Show errors less severity in warnings with wp cli flag Oct 4, 2024
@davidperezgar
Copy link
Member Author

I've commited my proposal. To have less severity errors as warnings with the flag: --include-error-severity. That will include less severity errors as warnings.

@swissspidy
Copy link
Member

A Behat test covering this change would be beneficial.

@swissspidy swissspidy added this to the 1.3.0 milestone Oct 11, 2024
@davidperezgar
Copy link
Member Author

Ok, I'm going to make it then.

@ernilambar ernilambar added the WP-CLI Issues related to WP-CLI label Oct 31, 2024
@davidperezgar davidperezgar changed the title CLI: Treat errors below severity threshold as error_extra CLI: Treat errors below severity threshold as warnings Nov 3, 2024
@felixarntz
Copy link
Member

I like the approach using a different type.

How about this?

  • Use custom type ERRORS_LOW_SEVERITY for low severity errors.
  • Do the same for warnings, i.e. add a flag --include-low-severity-warnings, and if that is set, include low severity warnings under WARNINGS_LOW_SEVERITY.

WDYT?

@davidperezgar
Copy link
Member Author

Hello,
I see that is a good approach and all will be happy with that solution.

@davidperezgar
Copy link
Member Author

Done! and ready to review!

@davidperezgar
Copy link
Member Author

It's strange as it works BEHAT tests in my local installation, but is failing.

@ernilambar
Copy link
Member

It's strange as it works BEHAT tests in my local installation, but is failing.

composer run behat -- tests/behat/features/plugin-check-severity.feature is not passing locally in my local setup.

@davidperezgar
Copy link
Member Author

Ok Thanks Nilambar

@davidperezgar
Copy link
Member Author

Finished!

Copy link
Member

@ernilambar ernilambar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@ernilambar
Copy link
Member

CC @felixarntz for re-review. 😊

@felixarntz felixarntz mentioned this pull request Nov 11, 2024
Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one note on WPCS, otherwise LGTM!

includes/CLI/Plugin_Check_Command.php Outdated Show resolved Hide resolved
@ernilambar ernilambar merged commit fe8ea10 into trunk Nov 12, 2024
29 checks passed
@ernilambar ernilambar deleted the 691-show-errors-with-severity-less-than-a-number-as-a-warning branch November 12, 2024 09:27
@davidperezgar
Copy link
Member Author

Thanks!

@dd32
Copy link
Member

dd32 commented Dec 5, 2024

Any reason these output types are pluralised?

ie. The types are now:

  • ERROR
  • ERRORS_LOW_SEVERITY
  • WARNING
  • WARNING_LOW_SEVERITY

@ernilambar
Copy link
Member

Followup PR - #818

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WP-CLI Issues related to WP-CLI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show errors with severity less than a number as a warning
6 participants