Analysiert den Code auf mögliche Probleme:
Schnell und einfach mit Composer
composer global require phpmd/phpmd
phpmd {source} {format} {rule} > {output}
~/.composer/vendor/bin/phpmd module/ xml codesize > codesize.xml
Findet doppelten Code
Schnell und einfach mit Composer
composer global require sebastian/phpcpd
phpcpd {source}
~/.composer/vendor/bin/phpcpd module/
phpcpd 2.0.2 by Sebastian Bergmann.
Found 3 exact clones with 138 duplicated lines in 5 files:
- module/ShowcaseReelAdmin/src/ShowcaseReelAdmin/Controller/ReelController.php:274-332
module/ShowcaseReelAdmin/src/ShowcaseReelAdmin/Controller/ReelController.php:409-467
- module/ShowcaseReelAdmin/src/ShowcaseReelAdmin/Model/Table/ProjectTable.php:118-159
module/ShowcaseReelAdmin/src/ShowcaseReelAdmin/Model/Table/ReelTable.php:124-165
- module/ShowcaseReelAdmin/src/ShowcaseReelAdmin/Form/ReelForm.php:79-118
module/ShowcaseReelAdmin/src/ShowcaseReelAdmin/Form/ProjectForm.php:69-108
0.78% duplicated lines out of 17777 total lines of code.
Time: 543 ms, Memory: 16.00Mb
Sucht und findet Abweichungen von den Coding-Standards
Schnell und einfach mit Composer
composer global require squizlabs/php_codesniffer
phpcs --standard={standard} {source}
~/.composer/vendor/bin/phpcs --standard=PSR2 -a module/
FILE: ...w/code-review/rocks-rocketshare/module/ShowcaseClient/Module.php
----------------------------------------------------------------------
FOUND 30 ERRORS AFFECTING 26 LINES
----------------------------------------------------------------------
5 | ERROR | [x] Whitespace found at end of line
6 | ERROR | [x] Whitespace found at end of line
13 | ERROR | [x] Whitespace found at end of line
14 | ERROR | [x] Whitespace found at end of line
16 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 2
17 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 2
18 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
22 | ERROR | [x] Whitespace found at end of line
24 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 2
25 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 2
26 | ERROR | [x] Line indented incorrectly; expected at least 8 spaces, found 4
28 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 4
28 | ERROR | [x] Expected 1 space after IF keyword; 0 found
28 | ERROR | [x] Expected 1 space after closing parenthesis; found "\n "
29 | ERROR | [x] Line indented incorrectly; expected at least 8 spaces, found 4
30 | ERROR | [x] Line indented incorrectly; expected at least 12 spaces, found 7
30 | ERROR | [x] Whitespace found at end of line
34 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
38 | ERROR | [x] Whitespace found at end of line
41 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 2
42 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 2
43 | ERROR | [x] Line indented incorrectly; expected at least 8 spaces, found 4
43 | ERROR | [x] Whitespace found at end of line
46 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
51 | ERROR | [x] Whitespace found at end of line
53 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 2
54 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 2
55 | ERROR | [x] Line indented incorrectly; expected at least 8 spaces, found 4
56 | ERROR | [x] Line indented incorrectly; expected at least 8 spaces, found 6
62 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
----------------------------------------------------------------------
PHPCBF CAN FIX THE 30 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
~/.composer/vendor/bin/phpcs -i
The installed coding standards are Squiz, PSR1, MySource, PHPCS, PEAR, PSR2 and Zend
Für fast jedes Open-Source Projekt gibt es fertige Sniffs.
composer global require wp-coding-standards/wpcs
ln -s ~/.composer/vendor/wp-coding-standards/wpcs/WordPress/ ~/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/
~/.composer/vendor/bin/phpcs -i
The installed coding standards are DrupalPractice, Squiz, PSR1, MySource, Drupal, Symfony2, WordPress, PHPCS, PEAR, PSR2, Zend and Symfony2
Misst und analysiert die Struktur des PHP Projekts
Schnell und einfach mit Composer
composer global require phploc/phploc
phploc {source}
~/.composer/vendor/bin/phploc module/
phploc 2.1.1 by Sebastian Bergmann.
Directories 46
Files 121
Size
Lines of Code (LOC) 17777
Comment Lines of Code (CLOC) 4756 (26.75%)
Non-Comment Lines of Code (NCLOC) 13021 (73.25%)
Logical Lines of Code (LLOC) 3755 (21.12%)
Classes 3265 (86.95%)
Average Class Length 30
Minimum Class Length 0
Maximum Class Length 273
Average Method Length 3
Minimum Method Length 0
Maximum Method Length 61
Functions 25 (0.67%)
Average Function Length 0
Not in classes or functions 465 (12.38%)
Cyclomatic Complexity
Average Complexity per LLOC 0.16
Average Complexity per Class 6.72
Minimum Class Complexity 1.00
Maximum Class Complexity 71.00
Average Complexity per Method 1.80
Minimum Method Complexity 1.00
Maximum Method Complexity 31.00
Dependencies
Global Accesses 2
Global Constants 0 (0.00%)
Global Variables 0 (0.00%)
Super-Global Variables 2 (100.00%)
Attribute Accesses 593
Non-Static 592 (99.83%)
Static 1 (0.17%)
Method Calls 3310
Non-Static 3282 (99.15%)
Static 28 (0.85%)
Structure
Namespaces 37
Interfaces 1
Traits 0
Classes 107
Abstract Classes 8 (7.48%)
Concrete Classes 99 (92.52%)
Methods 779
Scope
Non-Static Methods 777 (99.74%)
Static Methods 2 (0.26%)
Visibility
Public Methods 706 (90.63%)
Non-Public Methods 73 (9.37%)
Functions 61
Named Functions 0 (0.00%)
Anonymous Functions 61 (100.00%)
Constants 38
Global Constants 0 (0.00%)
Class Constants 38 (100.00%)