phploc output explanation

試著忘記壹切 提交于 2019-12-03 07:53:37

Low cyclomatic complexity is good, high is bad; statics are hard to unit test, but (while some people consider them as bad as eval) they do serve a purpose; other measures from phploc are subject to interpretation.

But you should really be using phploc alongside other tools like pdepend, and phpmd. The pdepend site in particular explains a lot of the analytics used, and the phpmd output is pretty self-explanatory

EDIT

As a comparison, the code that I'm currently working on (https://github.com/MarkBaker/PHPGeodetic): I'm reasonably happy with the level of abstract/concrete classes, though it could go a bit higher; I've one method with a higher cyclomatic complexity that's enough to skew those figures a bit, but that doesn't readily lend itself to being broken down; and a handful of longer methods (but not long enough to trigger phpmd warnings).

Lines of Code (LOC):                               4003
  Cyclomatic Complexity / Lines of Code:           0.07
Comment Lines of Code (CLOC):                      1580
Non-Comment Lines of Code (NCLOC):                 2423

Namespaces:                                           0
Interfaces:                                           1
Traits:                                               0
Classes:                                             25
  Abstract:                                           4 (16.00%)
  Concrete:                                          21 (84.00%)
  Average Class Length (NCLOC):                     103
Methods:                                            160
  Scope:
    Non-Static:                                     129 (80.62%)
    Static:                                          31 (19.38%)
  Visibility:
    Public:                                         131 (81.88%)
    Non-Public:                                      29 (18.12%)
  Average Method Length (NCLOC):                     16
  Cyclomatic Complexity / Number of Methods:       2.12

Anonymous Functions:                                  2
Functions:                                            0

Constants:                                           66
  Global constants:                                   0
  Class constants:                                   66

Overall, I'm tempted to work with the 80:20 rule for Public/Private, Non-Static/Static and for Concrete/Abstract; but a great deal depends on what you're actually coding

Probably more important is Cyclomatic Complexity/Number of Methods... I don't like that figure being too high; but if it gets up above a 2.5 average I'll be looking at phpmd stats a lot more closely

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!