Nice work. Likely we could adapt some approaches from, e.g., the PEAR PHP_Beautifier package, http://pear.php.net/package/PHP_Beautifier. For actually fixing up non-compliant code, contributors could use PHP_Beautifier directly, if a noble volunteer would write a new "filter" for Drupal coding styles, modelled on, e.g., the existing PEAR filter (see the file Beatutifier/Filter/PEAR.filter.php in the distribution). Nedjo ----- Original Message ----- From: "Dries Buytaert" <dries@buytaert.net> To: <drupal-devel@drupal.org> Sent: Saturday, February 19, 2005 4:15 AM Subject: Re: [drupal-devel] Checking coding style of contributed modules
Dries Buytaert wrote:
Right on. I'm a True Believer of automation and self-organization (if possible).
If we'd have a 'code check' script -- even an extremely basic one -- I could install it on drupal.org and run the script once or twice a day on _each_ project in the contributions repository and link the report from the project pages.
For example, on the project page of the image module (http://drupal.org/project/image), there would be a link called 'View code report' that points to the image module's code report, generated by the script.
Of course, it is nothing like a real review and it might generate false positives but it could easily catch dozens of issues and encourage good coding style without manual intervention and within a few hours. After all, it is easy enough to detect tabs, '} else' or the absence of '{}' in SQL queries.
I slapped together the foundations of a code checker scripts and installed it on drupal.org. It took me 50 minutes to write and install. It catched hundreds of (small) issues already, and will continue to catch many more in future to it most certainly pays off.
The code: ---------
The code lives at: http://cvs.drupal.org/viewcvs/drupal/contributions/tricks/code-checker/
Currently, it checks for '} else', SQL queries that lack '{}' (prefix), and CamelCase function names.
Drupal.org: -----------
At the bottom of the project pages, there is a new link called 'View code report'. For example, take a look at http://drupal.org/project/image. The image module's report looks like: http://drupal.org/files/projects/image.status.
Note that the report is generated against the HEAD version of each project and is updated a few times a day.
What is next? -------------
Of course, we'll want to integrate it better and make it visually more appealing. Also, we'll want to add many more tests.
I won't be able to work on it until after DrupalCon but you're all invited to add more tests. I'd be happy to install newer versions on drupal.org as soon they hit CVS.
So, who's first to add a new test?
-- Dries Buytaert :: http://www.buytaert.net/