Exakat 1.1.9 review

Exakat 1.1.9 spins off the ‘Code Favorites’ reports, which tells you what is the actual personality of your coding habits : check it out, it’s always impressive. The engine also offers a new analysis, that counts parameters and suggest refactoring methods with more than 8 parameters. And the documentation received a lot of new illustrations. So, ladies and gentlemen, welcome to the Exakat 1.1.9 review.

Number of parameters in methods

Starting from his tweet from Adam Wathan, I wondered how ‘too many parameters in a method’ applies to PHP code source. So, I added quickly a paremeter count to Exakat, and started counting parameters in Open Source code. The results are impressive :

Almost every application has between 0 and 4 parameters. Then, 5 or 6 parameters functions are around the average of 50%. And finally, methods with 6 parameters are getting very rare.

 

As usual, there are exceptions, and it wasn’t long before I could find an application featuring up to 19 parameters in a function. This is screaming for refactoring!

So, Exakat now reports methods that sports 8 parameters or more for refactoring.

A side note : this first diagramm was done over a short corpus of 50 applications, but it is already yielding interesting results.

Code favorite’s Report

The Ambassador has a ‘Code Favorites’ section : it reports code patterns that have at least two alternatives, and presents the one that was chosen in the audited code. Or not.

Take the class ‘echo or print’ war. Exakat looks in the code, and find all occurrences of echo and print. It also adds occurrences of short tags <?=, and computes statistics on the three. If the current code includes more than 90% of one solution, for example echo, it declares the others as issues. With an overwehlming majority of echo, print and <?= are persona non grata and should be removed. Of course, it may also be print that is chosen.

 

Code favorites
Everytime PHP offers two alternatives for the same features, the code has a choice to make : choose echo, choose print, or choose any of them. All those choices are characteristics of your coding style : they make you unique.

When neither of the alternative is a dominant solution, the situation is said ‘not decided’ and Exakat doesn’t report any issues : after all, it is also a choice not to pay attention to those details.

Code favorites are now extracted from Ambassador : you may export them directly as JSON, to collect various statistics across a large number of projects, and build a in-house coding guide. Or, you may also check what is really your code’s choice.

Upgraded documentation

Exakat has a serious facelift. All the reports are now illustrated, and we started adding real code

Reports illustrations

First, all the reports are now illustrated. Take a look at the gallery online : reports provide issues in list, for machine to read or expert auditors to skim. They also provide graphical results, like UML diagrams, code flowers or exceptions trees. Take a look, we’ll wait!

Real code illustrations

Currently, every analysis is illustrated with an academic piece of code : code that is crafted for explaining the situation, in a short amount of LOC. Since Exakat keeps an eye on over 1800 Open Source PHP projects, we started adding examples found in real code.

Happy PHP code reviews

All the 344 analyzers are presented in the docs, including the gentle Could Use DIR: Use ‘DIRconstant to access the current file’s parent directory. It’s a common PHP bug, rating at 15%, but it makes the code really cleaner.

Download Exakat on exakat.io, install it with Docker, upgrade it with ‘exakat.phar upgrade -u’ and like us on github.