I want to use the official coding standard for Joomla! 4 to check my own Joomla! components.
I can't find the official coding standard anywhere for Joomla! 4 (neither the written rules or the phpcs ruleset). I found this github repo but that seems to only be the standard for Joomla! 3. At least it's the not Joomla! 4 standard. Because after running composer install
it installs the ruleset to the following directory: libraries/vendor/joomla/cms-coding-standards/lib/Joomla-CMS/ruleset.xml
, which is different from the one in the linked repository. So it would seem I found the correct ruleset.xml since it is included in the 4.0-dev branch. But when I try to use this ruleset by running ./libraries/vendor/bin/phpcs libraries/cms --report=checkstyle --extensions=php --encoding=utf-8 -p --standard=./libraries/vendor/joomla/cms-coding-standards/lib/Joomla-CMS
. Which is the same configuration as specified in the build.xml. I get the following error:
PHP Fatal error: Uncaught PHP_CodeSniffer_Exception: Referenced sniff "Joomla.Commenting.FileComment" does not exist in /home/jor/Projects/joomla-cms/libraries/vendor/squizlabs/php_codesniffer/CodeSniffer.php:1167
It seems to me the Joomla! rules are not installed. Which makes sense since the libraries/vendor/joomla/cms-coding-standards/lib/Joomla-CMS/
directory doesn't contain a sniffs directory which is required by phpcs to know how to enforce the rules defined in the ruleset.xml. So how do I use the.
Additionally there in the build.xml there seem to be more tools running checks on the php code:
Trying to use ant to run the build.xml is no luck as i get the same errors and more from other tools. I will spare you the output of that.
If I am missing some official Joomla! documentation where this is defined I am sorry, I did try to find documentation where this is defined.
I do see others working on fixing the codestyle so I assume others have gotten this to work on their local machine rather than see for example this Pull Request #25471
I have 3 questions:
P.S. I'm not sure if i should label this as Feature Request or bug or something else on Github.
Labels |
Added:
?
|
Labels |
Added:
J4 Issue
|
Title |
|
Status | New | ⇒ | Discussion |
@JorSanders if Issue is solved please close it.
@JorSanders the wait is for #25548 being merged, when it does, then your codestyle sniffer will work.
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-07-17 07:04:55 |
Closed_By | ⇒ | JorSanders |
https://github.com/joomla/cms-coding-standards is an extension of https://github.com/joomla/coding-standards with some extra defaults optimized for the CMS environment (unfortunately the ruleset in the CMS standards repo really is only good out-of-the-box for this repo).
So use https://github.com/joomla/coding-standards as your base standard, and use https://github.com/joomla/cms-coding-standards to build an extended ruleset for your projects that adequately ignores things that cannot be made 100% PHPCS compliant.