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

How to make checks that Search first, Diagnose and Analyze later #826

Closed
davidperezgar opened this issue Dec 10, 2024 · 2 comments
Closed

Comments

@davidperezgar
Copy link
Member

We have some checks to develop like Generic Names, Readme privacy and more.
What we need is to search for all functions used in a plugin, then analyze them and diagnose the problem.

We don't know how to approach this problem. What we see is that we show the error individually but we need to show globally.

For example in Generic Names, we have to look for functions/class/etc names and after analyze them for example in an array, and then show the problem.

So the check would be like:
Search Functions names > Make them in a list > Review and diagnose which are problematic > Make the error for each of them.

It's similar to the other Check related with privacy. We have to look al remotes calls, then see in the readme if the privacy notes are written, if not, warn to the user.

What do you think?

CC: @mukeshpanchal27 @felixarntz @swissspidy

@swissspidy
Copy link
Member

I thought the plugins team already had such a tool internally that does this for detecting the function prefix that is likely used.

Is that what you are trying to solve here? Or what are you trying to solve with such a tool?

Generally speaking you'll probably want to use RecursiveDirectoryIterator to get a list of all PHP files. Abstract_File_Check::get_files() already handles this. Then you need something like PHP-Parser to scan the PHP files for all functions to then analyze their names. I was just looking at https://github.com/johnbillion/wp-compat/blob/c86aa3c71b560817689723f41bd551f5c10e2a22/generate.php today which does something like that.

Once you have your function names you can do whatever you want with them.

@davidperezgar
Copy link
Member Author

Yes, that makes sense. I'll try it then.

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

No branches or pull requests

2 participants