Magento 2.3 EE code lines metrics

Yegor Shytikov
4 min readFeb 25, 2020

Analyzing Magento 2 vendor/Magento/* folder

phploc is a tool for quickly measuring the size and analyzing the structure of a PHP project.

Author(s)Sebastian Bergmann

Website: https://github.com/sebastianbergmann/phploc

The same text data:

[ec2-user@ip-172-31-7-147 magento2EE]$  phploc vendor/magento/
phploc 6.0.0 by Sebastian Bergmann.
Directories 11586
Files 30369
Size
Lines of Code (LOC) 3424574
Comment Lines of Code (CLOC) 1095728 (32.00%)
Non-Comment Lines of Code (NCLOC) 2328846 (68.00%)
Logical Lines of Code (LLOC) 606680 (17.72%)
Classes 590694 (97.37%)
Average Class Length 21
Minimum Class Length 0
Maximum Class Length 1415
Average Method Length 4
Minimum Method Length 0
Maximum Method Length 571
Average Methods Per Class 4
Minimum Methods Per Class 0
Maximum Methods Per Class 371
Functions 524 (0.09%)
Average Function Length 0
Not in classes or functions 15462 (2.55%)
Cyclomatic Complexity
Average Complexity per LLOC 0.16
Average Complexity per Class 4.32
Minimum Class Complexity 1.00
Maximum Class Complexity 788.00
Average Complexity per Method 1.83
Minimum Method Complexity 1.00
Maximum Method Complexity 331.00
Dependencies
Global Accesses 1370
Global Constants 638 (46.57%)
Global Variables 30 (2.19%)
Super-Global Variables 702 (51.24%)
Attribute Accesses 261557
Non-Static 259025 (99.03%)
Static 2532 (0.97%)
Method Calls 719143
Non-Static 691686 (96.18%)
Static 27457 (3.82%)
Structure
Namespaces 9674
Interfaces 1852
Traits 7
Classes 26210
Abstract Classes 685 (2.61%)
Concrete Classes 25525 (97.39%)
Final Classes 3 (0.01%)
Non-Final Classes 25522 (99.99%)
Methods 119558
Scope
Non-Static Methods 118136 (98.81%)
Static Methods 1422 (1.19%)
Visibility
Public Methods 92049 (76.99%)
Protected Methods 19910 (16.65%)
Private Methods 7599 (6.36%)
Functions 1604
Named Functions 97 (6.05%)
Anonymous Functions 1507 (93.95%)
Constants 14013
Global Constants 65 (0.46%)
Class Constants 13948 (99.54%)
Public Constants 13787 (98.85%)
Non-Public Constants 161 (1.15%)

Magento 2 EE Complexity report 2

PhpMetrics provides software metrics about PHP projects and classes.

It generates readable and accessible reports about maintainability, quality, and complexity of a source code.

Author: Jean-François Lépine

Website:http://www.phpmetrics.org/

Text data:

LOC
Lines of code 1228086
Logical lines of code 652105
Comment lines of code 576668
Average volume 461.21
Average comment weight 42.79
Average intelligent content 42.79
Logical lines of code by class 46
Logical lines of code by method 11
Object oriented programming
Classes 14045
Interface 1701
Methods 59005
Methods by class 4.2
Lack of cohesion of methods 1.42

Coupling
Average afferent coupling 2.42
Average efferent coupling 3.99
Average instability 0.83
Depth of Inheritance Tree 1.08

Package
Packages 5563
Average classes per package 2.83
Average distance 0.12
Average incoming class dependencies 7.6
Average outgoing class dependencies 6.7
Average incoming package dependencies 4.94
Average outgoing package dependencies 5.24
Complexity
Average Cyclomatic complexity by class 6.62
Average Weighted method count by class 10.04
Average Relative system complexity 237.89
Average Difficulty 6.3

Bugs
Average bugs by class 0.15
Average defects by class (Kan) 0.55
Violations
Critical 0
Error 1327
Warning 2598
Information 526

The report is composed from different parts :

  1. The tabular area
  2. The Bubbles area
  3. The Custom chart area
  4. The Abstractness / Instability area

URL:

http://m2ce.umsf-it.dp.ua/pub/static/MAgento2EEReport/panel.html

When any information has color, PhpMetrics try to get your attention about significant information:

  • Green: all looks correct
  • Yellow: correct, but be careful
  • Red: anomaly detected

2. The tabular area

This area display main metrics for each package. Do not hesitate to click on the + button (on the left) in order to explore packages and to search specifc class.

You can hover titles of columns to get more description of the metric. Abbrevations are explained in the documentation.

3. The Bubbles area

The bubbles area is the most “visual” part of the report.

  • Each file is symbolized by a circle
  • Size of the circle represents the Cyclomatic complexity
  • Color of the circle represents the Maintainability Index
  • Move your cursor on a circle to have details

Large red circles will be probably hard to maintain.

Magento 2 complexity and maintainability

4. The Custom chart area

This area can display all the charts you want. You just need to select, at the bottom, the data you want to be displayed.

--

--

Yegor Shytikov

True Stories about Magento 2. Melting down metal server infrastructure into cloud solutions.