Il y a un container fourni par phaudit qui contient déjà des outils pour auditer le code.
Voici la ligne de commande pour l’installer
1
docker pull jolicode/phaudit
Et je me place dans mon répertoire projet
Listes des programmes
PHPLocphploc donne le nombre de ligne, le nombre de classes etc ..
123456789101112131415
docker run -t -i -v `pwd`:/project jolicode/phaudit phploc src
Directories 10
Files 91
Size
Lines of Code (LOC) 7295
Comment Lines of Code (CLOC) 3228 (44.25%)
Non-Comment Lines of Code (NCLOC) 4067 (55.75%)
Logical Lines of Code (LLOC) 774 (10.61%)
Classes 711 (91.86%)
Average Class Length 8
Minimum Class Length 0
Maximum Class Length 67
Average Method Length 1
Minimum Method Length 0
PHP Mess Detectorphpmd donne un retour sur la qualité du code (nommage des variables etc..)
1234567
phaudit phpmd . text naming
/project/src/Allmy/Protocol/LineReceiver.php:38 Avoid variables with short names like $b. Configured minimum length is 3.
/project/src/Allmy/Reactor/StreamSelectReactor.php:32 Avoid variables with short names like $id. Configured minimum length is 3.
/project/src/Allmy/Reactor/StreamSelectReactor.php:43 Avoid variables with short names like $id. Configured minimum length is 3.
/project/src/Allmy/Reactor/StreamSelectReactor.php:53 Avoid variables with short names like $id. Configured minimum length is 3.
...
...
PHP_CodeSnifferphpcs erreur de convention de code (Psr-..) et phpcbfpour les fixer automatiquement
123456789101112
docker run -t -i -v `pwd`:/project jolicode/phaudit phpcs src/Allmy/Reactor/StreamSelectReactor.php
FILE: /project/src/Allmy/Reactor/StreamSelectReactor.php
----------------------------------------------------------------------
FOUND 85 ERRORS AND 3 WARNINGS AFFECTING 63 LINES
----------------------------------------------------------------------
2 | ERROR | [ ] Missing file doc comment
11 | ERROR | [ ] Missing class doc comment
15 | ERROR | [ ] Private member variable "timers" must be
.....
.....
.....
275 | ERROR | [ ] Parameter tags must be grouped together in a doc
docker run -t -i -v `pwd`:/project jolicode/phaudit phpcpd src
Found 2 exact clones with 101 duplicated lines in 4 files:
- /project/src/Allmy/Stream/Factory.php:9-53
/project/src/Allmy/Internet/Factory.php:9-53
- /project/src/Allmy/Transport/TcpServer.php:9-66
/project/src/Allmy/Socket/Server.php:9-66
1.38% duplicated lines out of 7295 total lines of code.
d’autre commandes que je connais un peu moins
PHP_Dependpdepend donnes des analyses, dépendences, complexités etc..