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

Allow static checks to be run against an arbitrary path #490

Merged

Conversation

davidperezgar
Copy link
Member

What we need for the submission form from wordpress.org is run static checks in an arbitrary path. It's helpful as well for any developer user to directly run static checks in any directory.

Resolves #478

@davidperezgar davidperezgar linked an issue Jul 3, 2024 that may be closed by this pull request
Copy link

github-actions bot commented Jul 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: ernilambar <[email protected]>
Co-authored-by: swissspidy <[email protected]>
Co-authored-by: mukeshpanchal27 <[email protected]>
Co-authored-by: joemcgill <[email protected]>

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

@swissspidy
Copy link
Member

I'm out of office until Monday but happy to review then.

At first glance I'd say the is_dir logic is at the wrong level. If you pull it higher up, then you don't to worry about naming or anything. For example doing that in Abstract_Check_Runner::get_plugin_basename would be better. No need to touch get_plugin_basename_from_input() at all.

Also, this would be an excellent candidate to write Behat tests for.

Happy to help with both once I'm back.

@ernilambar
Copy link
Member

I tested PR and it is not working for plugin in external location as expected.
Few checks are working though.

In Plugin_Context there is protected $main_file; which is used in several checks. This expects the main file of the plugin but in external plugin, this variable just has plugin path. So there are few errors in the output.

Screenshot 2024-07-04 at 4 51 43 PM

Like in Plugin_Header_Text_Domain_Check, there is like this:

$plugin_main_file = WP_PLUGIN_DIR . '/' . $result->plugin()->basename();

May be we should fix $main_file in the beginning and access same property in all checks rather than evaluating main file like above.

@davidperezgar
Copy link
Member Author

Thanks @ernilambar for your feedback. I've detected that problem, and I've committed a fix. Update the PR and it should work.

@davidperezgar davidperezgar removed the request for review from frantorres July 8, 2024 11:15
@swissspidy swissspidy added this to the 1.0.2 milestone Jul 9, 2024
@swissspidy swissspidy merged commit 8ffd566 into trunk Jul 9, 2024
21 checks passed
@swissspidy swissspidy deleted the 478-allow-static-checks-to-be-run-against-an-arbitrary-path branch July 9, 2024 08:09
@davidperezgar
Copy link
Member Author

davidperezgar commented Jul 9, 2024

None, it's working

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

Successfully merging this pull request may close these issues.

Allow static checks to be run against an arbitrary path
4 participants