Actions

Proposals/Code Standards checking on commit

From Mahara Wiki

< Proposals
Revision as of 14:57, 25 Ocak 2023 by Gold (talk | contribs) (Adding the discovery for GrumPHP and PHP_CodeSniffer)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The proposal is that we add a git pre-commit hook that checks the code about to be committed for standards compatibility. Many of the developers are also employed by Catalyst IT and the Drupal team there already use this approach. Adding initial standards checking should be straight forward and we already have a template, in the form of the Drupal Coder module, to use as guide for adding any Mahara specific standards we want to enforce.

While working through the minutes I followed links for GrumPHP and PHP_CodeSniffer.

tl;dr;

GrumPHP uses PHP_CodeSniffer so we have one project that we actually need to focus on when writing the code standards.

We use GrumPHP in the git commit hook that is already in the `make push` step allowing us to remove `make minaccept`, or replace it with a call to Grupphp, and when we want to do a project wide check we can call `phpsc` directly.

Discovery

Starting at GrumPHP (which we use as the commit checker in Drupalland) I checked to see how Drupal does it and that lead me to grumphp-drupal.

Checking the Ruleset there I found that it was referencing vendor/drupal/coder/coder_sniffer/Drupal. The Drupal Coder module is the module that houses the PHP_CodeSniffer sniffs for Drupal compatibility.

This tells us that GrumPHP is using PHP_CodeSniffer and we just need to focus on the latter for any custom compatibility rules.