Ecstore代码复杂度

注: Ecstore是一款企业级B2C电子商城系统,与Ecshop一样同出商派。

  写了这么多年代码,如果有人问你,你的项目有多少个文件、多少行代码、多少个方法,你可以用确切的数据回答他吗?
  当项目经理、产品经理给你安排一个他们觉得非常简单的需求时,你可以用确切的数据告诉他这有多复杂吗?
  下面给你介绍一个代码复杂度检测工具:PHPLOC

[lru @ bin]$./phploc ~/project/b2c/ecstore
phploc 4.0.0 by Sebastian Bergmann.

Directories                                        995
Files                                             2515

Size
  Lines of Code (LOC)                           340269
  Comment Lines of Code (CLOC)                   72154 (21.20%)
  Non-Comment Lines of Code (NCLOC)             268115 (78.80%)
  Logical Lines of Code (LLOC)                   86290 (25.36%)
    Classes                                      81433 (94.37%)
      Average Class Length                          41
        Minimum Class Length                         0
        Maximum Class Length                      1078
      Average Method Length                          7
        Minimum Method Length                        0
        Maximum Method Length                      214
    Functions                                     2150 (2.49%)
      Average Function Length                        9
    Not in classes or functions                   2707 (3.14%)

Cyclomatic Complexity
  Average Complexity per LLOC                     0.36
  Average Complexity per Class                   16.22
    Minimum Class Complexity                      1.00
    Maximum Class Complexity                    382.00
  Average Complexity per Method                   3.90
    Minimum Method Complexity                     1.00
    Maximum Method Complexity                   135.00

Dependencies
  Global Accesses                                 4771
    Global Constants                               924 (19.37%)
    Global Variables                               205 (4.30%)
    Super-Global Variables                        3642 (76.34%)
  Attribute Accesses                             22406
    Non-Static                                   21875 (97.63%)
    Static                                         531 (2.37%)
  Method Calls                                   55404
    Non-Static                                   37543 (67.76%)
    Static                                       17861 (32.24%)

Structure
  Namespaces                                         0
  Interfaces                                        83
  Traits                                             0
  Classes                                         1896
    Abstract Classes                                45 (2.37%)
    Concrete Classes                              1851 (97.63%)
  Methods                                        10759
    Scope
      Non-Static Methods                         10179 (94.61%)
      Static Methods                               580 (5.39%)
    Visibility
      Public Methods                              9865 (91.69%)
      Non-Public Methods                           894 (8.31%)
  Functions                                        218
    Named Functions                                213 (97.71%)
    Anonymous Functions                              5 (2.29%)
  Constants                                        366
    Global Constants                               221 (60.38%)
    Class Constants                                145 (39.62%)

以上就是phploc 检测 ecstore v2.3.80的代码情况。可以看出来:

  1. ecstore有** 995 **个php目录
  2. ecstore有** 2515 **个php文件
  3. ecstore有** 340269 **行php代码
    ...

PHPLOC的安装非常简单:

$ wget https://phar.phpunit.de/phploc.phar
$ php56 phploc.phar
$ composer require --dev phploc/phploc 
$ cd vendor/bin/
$ ./phploc ~/project/b2c/ecstore

** 注: **当然还有别的工具,如:phpmetrics,请自行谷歌。

你可能感兴趣的:(Ecstore代码复杂度)