bug PR-4.4-dev Pending

User tests: Successful: Unsuccessful:

avatar richard67
richard67
1 Apr 2023

Pull Request for Issue # .

Summary of Changes

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.

Testing Instructions

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.

  1. Show the help: php ./build/check_ruleset_xml.php --help.
  2. Check the "ruleset.xml" file in the Joomla root folder without fixing the file: php ./build/check_ruleset_xml.php.
  3. Check the "ruleset.xml" file in the Joomla root folder and fix the file: php ./build/check_ruleset_xml.php --fix.
  4. Check the "ruleset.xml" file in the "build/psr12" folder: php ./build/check_ruleset_xml.php --file ./build/psr12/ruleset.xml.
  5. Free test: Feel free to add some exclude patterns for files and folders which don't exist to some ruleset XML file, then check that file as shown above in steps 2 or 3, depending on which file you have modified or created.

Actual result BEFORE applying this Pull Request

There is no tool to check if exclude patterns in a ruleset XML file for phpcs are still relevant or obsolete.

Expected result AFTER applying this Pull Request

There is a PHP CLI script "check_ruleset_xml.php" in the "build" folder.

  1. Show the help:
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)

  1. Check the "ruleset.xml" file in the Joomla root folder without fixing the file.

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

  1. Check the "ruleset.xml" file in the Joomla root folder and fix the file.

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.
  1. Check the "ruleset.xml" file in the "build/psr12" folder. On a clean, current 4.3-dev branch:
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.

Link to documentations

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.

avatar joomla-cms-bot joomla-cms-bot - change - 1 Apr 2023
Category Repository
avatar richard67 richard67 - open - 1 Apr 2023
avatar richard67 richard67 - change - 1 Apr 2023
Status New Pending
avatar richard67 richard67 - change - 1 Apr 2023
Labels Added: PR-4.3-dev
avatar richard67 richard67 - edited - 1 Apr 2023
avatar richard67 richard67 - change - 1 Apr 2023
The description was changed
avatar brianteeman
brianteeman - comment - 1 Apr 2023

LGTM

avatar richard67 richard67 - change - 5 May 2023
The description was changed
avatar richard67 richard67 - edited - 5 May 2023
avatar richard67 richard67 - change - 9 May 2023
Labels Added: bug
avatar laoneo
laoneo - comment - 10 May 2023

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.

avatar richard67
richard67 - comment - 10 May 2023

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.

avatar richard67 richard67 - change - 12 May 2023
Title
Add build tool to check ruleset.xml for obsolete exclude patterns
Add build tool to check ruleset.xml for obsolete exclude patterns and optionally fix the file
avatar richard67 richard67 - edited - 12 May 2023
avatar richard67 richard67 - change - 12 May 2023
The description was changed
avatar richard67 richard67 - edited - 12 May 2023
avatar richard67 richard67 - change - 12 May 2023
The description was changed
avatar richard67 richard67 - edited - 12 May 2023
avatar richard67 richard67 - change - 12 May 2023
The description was changed
avatar richard67 richard67 - edited - 12 May 2023
avatar richard67
richard67 - comment - 12 May 2023

I've added an option to fix the file and have updated testing instructions. Please test. Thanks in advance.

avatar richard67 richard67 - change - 18 May 2023
The description was changed
avatar richard67 richard67 - edited - 18 May 2023
avatar richard67 richard67 - change - 18 May 2023
The description was changed
avatar richard67 richard67 - edited - 18 May 2023
avatar richard67 richard67 - change - 18 May 2023
The description was changed
avatar richard67 richard67 - edited - 18 May 2023
avatar richard67 richard67 - change - 18 May 2023
The description was changed
avatar richard67 richard67 - edited - 18 May 2023
avatar richard67
richard67 - comment - 18 May 2023

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.

avatar richard67 richard67 - change - 18 May 2023
The description was changed
avatar richard67 richard67 - edited - 18 May 2023
avatar richard67 richard67 - change - 18 May 2023
The description was changed
avatar richard67 richard67 - edited - 18 May 2023
avatar laoneo laoneo - change - 26 Sep 2023
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
avatar laoneo laoneo - close - 26 Sep 2023
avatar laoneo laoneo - merge - 26 Sep 2023
avatar laoneo
laoneo - comment - 26 Sep 2023

Thanks!

Add a Comment

Login with GitHub to post a comment