Scrutinize your PHP

Earlier today I was looking at a pull request I had sent to an open source project on GitHub. It turns out the patch is likely rejected but something interesting popped out. Just below my PR there was a system comment.

Good to merge — Scrutinizer: No Comments — Travis: Passed

Now I know about continous integration with Travis from before but what was that Scrutinizer business?

Automated code reviews

Some Google searches later I found the source. Apparently it is the brain child of code machine Johannes Schmitt; known and greatly appreciated for all the awesome PHP libraries he has churned out over the years. The guy is a machine and it seems he keeps going.

Scritinizer is a service for automated code reviews. A live example shows us that this tool can take a code base like SonataCacheBundle, find within it a code snippet like this:

public function set(array $keys, $data, $ttl = 84600, array $contextualKeys = array())
{
    $cacheElement = new CacheElement($keys, $data, $ttl);

    $result = apc_store(
        $this->computeCacheKeys($keys),
        $cacheElement,
        $cacheElement->getTtl()
    );

    return $cacheElement;
}

… and automatically suggest how to improve it …

The assignment to $result is dead and can be removed.

Quite cool, huh? But it gets better.

This dead code check is just one out of fourteen checks in the PHP Analyzer tool. Then there is PHP Code Sniffer, PHP Mess Detector, SensioLabs Security Checker, etc, etc. Your PHP code will be thoroughly scrutinized for sure.

Scrutinize now

The service is entirely open and while I could not see any information about it; it seems it is still in public testing. Private repositories are supported and even they are free to use, thouhg I have no idea for how much longer.

So what are you waiting for? Go take it for a ride!

Published