During the setup of my development environment I stumbled accross Moodle's coding style (https://docs.moodle.org/dev/Coding_style) and the Code-checker (https://moodle.org/plugins/local_codechecker) multiple times. The latter runs like a charm from the web interface. However, I haven't been able to get it running on the command line (I need to integrate it into my CI pipeline).
I have installed PHP CodeSniffer via composer and I'm able to run it from my plugin root directory with the following command:
Then, I downloaded Code-checker and dropped it right into my plugin directory so that I can pass Moodle's code style's ruleset.xml via the --standard parameter:
vendor\bin\phpcs.bat --standard=codechecker\moodle\ruleset.xml src\version.php
Unfortunately, this results in the following error message:
ERROR: The specified autoload file "./../PHPCSAliases.php" does not exist
And, indeed, this file is not located inside the codechecker directory.
Following the instructions for PHPStorm integration on the GitHub page (https://github.com/moodlehq/moodle-local_codechecker) yields the same error when running PHPStorm's code inspector.
<autoload>./../PHPCSAliases.php</autoload>in codechecker\PHPCompatibility\ruleset.xml leads to the next, possibly worse, error:
PHP Fatal error: Interface 'PHP_CodeSniffer_Sniff' not found in C:\Users\xvlcw.zero\test \simplehtml2\codechecker\moodle\Sniffs\Commenting\InlineCommentSniff.php on line 27
Anyone having an idea?
Besides, is the Code-checker still being used? On the web interface the code checker suggests to run it on itself. Doing so uncovers 257 errors in 29 files. The creators of the checker don't seem to too convinced of the coding style they enforce... And, although I'm new to PHP development, I don't get why you would prohibit CamelCase in favor of whateverthisunreadablestyleiscalled. Other coding standards like PSR-2 and PEAR (and the developers of Code-checker) use CamelCase, too.
Anyway, I'd like to get it running if it's considered best practice for Moodle plugin development. I really appreciate any help