Static code analysis

After creating the #28855 ticket for WordPress Core I thought about making some BASH scripts to grep this kind of lines. For example: find PROJECT_DIR -iname "*.php" -exec php -l {} \; After some reading and googling I ended up reading Static analysis tools for PHP. I’m now just a WordPress newcomer, but read and heard a lot about WP’s code that it’s ugly or not “good” as some professional developers mention, OK they might be right, don’t care, WP is awesome and millions are using it, but this is another story. I like the WP community and the whole ecosystem, that’s why I care about it. This static code analysis could be beneficial for the WP and also other codebases. I know that IDE’s have such functionality, but some of these warnings are displayed via some small icons and we are human and can overlook these, but the software shouldn’t suffer from this. There are also devs who don’t use IDE’s as me, but rather for example stick with VIM, because of its awesome text movements. The above mentioned article mentioned PHP Analyzer that links to a commercial version of it so I tried the trial version on a forked WP GitHub repo. Screen Shot 2014-07-12 at 8.36.24 PM Screen Shot 2014-07-12 at 10.38.08 PM Screen Shot 2014-07-12 at 10.38.26 PM Screen Shot 2014-07-12 at 10.43.06 PMScreen Shot 2014-07-13 at 9.55.29 AM

 

The next day I found PHP analyzer on sourceforge which is outdated, but on https://github.com/scrutinizer-ci/php-analyzer/tree/legacy is an updated version. Christopher alse describes how does he use Grunt for PHP. Many thanks Chris for the posts 😉
UPDATE: My good friend suggested looking at http://www.sonarqube.org/