User tests: Successful: Unsuccessful:
Pull Request for Issue # .
This pull request (PR) adds a new, small tool (PHP CLI script) for checking any ruleset XML file for phpcs, by default the "ruleset.xml" file in the Joomla root, if it contains exclude patterns for files or folders which don't exist anymore because some PR has removed or moved that file or folder, and optionally fix the file.
I have used this tool to create PR's #40276 and #40277 .
I have used file()
to read the file and not simplexml_load_file
because I want to output the line number of the XML file to make it easier to manually review and fix the file.
The tool is limited to handle exclude patterns like we currently use them in the "ruleset.xml" file.
E.g. for folders: https://github.com/joomla/joomla-cms/blob/4.3-dev/ruleset.xml#L6-L17
Or files: https://github.com/joomla/joomla-cms/blob/4.3-dev/ruleset.xml#L32
I.e. anything which ends with "/" or "/*" is a folder, and anything else is a file, and any dots are escaped.
If in future more sophisticated expressions will be used in exclude patterns, the tool has to be adapted to that.
As the tool is a maintainer tool in the "build" folder, it doesn't go into any installation or update package, and so any feature freeze policy for the 4.3-dev branch due to the RC phase doesn't apply here.
For the same reason it does not need any documentation on docs.joomla.org .
It could make sense to add some documentation to manual.joomla.org if the tool becomes part of the regular release workflow.
But maybe that's not really necessary because it is so small that it's quite self explaining, and it has a description in the top comment block and a --help
option to show the help at the command line.
Copy the one file added by this PR to a branch of your choice into the build folder.
Then run the tool at the command line, e.g. with php ./build/check_ruleset_xml.php
when in the Joomla root folder.
php ./build/check_ruleset_xml.php --help
.php ./build/check_ruleset_xml.php
.php ./build/check_ruleset_xml.php --fix
.php ./build/check_ruleset_xml.php --file ./build/psr12/ruleset.xml
.There is no tool to check if exclude patterns in a ruleset XML file for phpcs are still relevant or obsolete.
There is a PHP CLI script "check_ruleset_xml.php" in the "build" folder.
php ./build/check_ruleset_xml.php --help
Usage: php ./build/check_ruleset_xml.php [options]
[options]:
--file <path>: Path to the PHPCS ruleset XML file to be checked, defaults to '/home/richard/lamp/public_html/joomla-cms-4.3-dev/ruleset.xml'.
--fix: Fix the XML file if any obsolete exclude patterns were found.
--help: Show this help output.
(Of course it shows a different path as default on your environment)
On a clean, current 4.3-dev branch with PR #40276 merged:
php ./build/check_ruleset_xml.php
Checking file '/home/richard/lamp/public_html/joomla-cms-4.3-dev/ruleset.xml' ...
... done.
No obsolete lines found.
On a clean, current 4.3-dev branch using the ruleset.xml file from before PR #40276 was merged:
Checking file '/home/richard/lamp/public_html/joomla-cms-4.3-dev/ruleset.xml' ...
Line no. 123: File "plugins/editors/tinymce/tinymce.php" doesn't exist.
Line no. 124: File "plugins/system/cache/cache.php" doesn't exist.
Line no. 239: File "plugins/content/emailcloak/emailcloak.php" doesn't exist.
Line no. 243: File "plugins/editors/none/none.php" doesn't exist.
... done.
You can download the ruleset.xml file from before PR #40276 was merged here: https://test5.richard-fath.de/ruleset.xml
On a clean, current 4.3-dev branch using the ruleset.xml file from before PR #40276 was merged:
php ./build/check_ruleset_xml.php --fix
Checking file '/home/richard/lamp/public_html/joomla-cms-4.3-dev/ruleset.xml' ...
Line no. 123: File "plugins/editors/tinymce/tinymce.php" doesn't exist.
Line no. 124: File "plugins/system/cache/cache.php" doesn't exist.
Line no. 239: File "plugins/content/emailcloak/emailcloak.php" doesn't exist.
Line no. 243: File "plugins/editors/none/none.php" doesn't exist.
... done.
Updating file '/home/richard/lamp/public_html/joomla-cms-4.3-dev/ruleset.xml' ...
... done.
php ./build/check_ruleset_xml.php --file ./build/psr12/ruleset.xml
Checking file './build/psr12/ruleset.xml' ...
Line no. 120: File "plugins/editors/tinymce/tinymce.php" doesn't exist.
Line no. 121: File "plugins/system/cache/cache.php" doesn't exist.
Line no. 236: File "plugins/content/emailcloak/emailcloak.php" doesn't exist.
Line no. 240: File "plugins/editors/none/none.php" doesn't exist.
... done.
Please select:
No documentation changes for docs.joomla.org needed
No documentation changes for manual.joomla.org needed
If someone points me to the right place at joomla/internal-documentation, i.e. in which file to which section I should add something, I can make a PR for that there if maintainers require that.
Category | ⇒ | Repository |
Status | New | ⇒ | Pending |
Labels |
Added:
PR-4.3-dev
|
Labels |
Added:
bug
|
Should this tool not be executed somewhere automatically in the development process. Not sure when, but if we have to execute it manually for every minor release it will get forgotten along the release build process.
Should this tool not be executed somewhere automatically in the development process. Not sure when, but if we have to execute it manually for every minor release it will get forgotten along the release build process.
@laoneo The tool shall advise the user (maintainer or release lead). The user still has to review the result and manually make the correction. The tool doesn't fix the file. I could add a "--fix" option for the latter. But where to call or use or document the tool is not my business since it's the release manager who have to use it. If you want to block this PR with these discussions I can close it. Right now we have nothing, no tool. With this PR we have some, that's an improvement.
Title |
|
I've added an option to fix the file and have updated testing instructions. Please test. Thanks in advance.
Should this tool not be executed somewhere automatically in the development process. Not sure when, but if we have to execute it manually for every minor release it will get forgotten along the release build process.
@laoneo The tool shall advise the user (maintainer or release lead). The user still has to review the result and manually make the correction. The tool doesn't fix the file. I could add a "--fix" option for the latter. But where to call or use or document the tool is not my business since it's the release manager who have to use it. If you want to block this PR with these discussions I can close it. Right now we have nothing, no tool. With this PR we have some, that's an improvement.
Update: I've added a --fix
option so the tool can be used in an automated action to create a pull request, similar to the translation updates. But I think the automated action should be created with a follow-up pull request, not with this one here.
Regarding documentation: If someone points me to the right place at joomla/internal-documentation, i.e. in which file to which section I should add something, I can make a PR for that there.
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2023-09-26 05:47:49 |
Closed_By | ⇒ | laoneo | |
Labels |
Added:
PR-4.4-dev
Removed: PR-4.3-dev |
Thanks!
LGTM