Skip to content

Commit f2b11cc

Browse files
authored
Merge pull request #412 from repzy/metrics-file
Add metrics description file
2 parents 2a91301 + 51d9e29 commit f2b11cc

File tree

2 files changed

+172
-0
lines changed

2 files changed

+172
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ Then open the generated `./myreport/index.html` file in your browser.
3131

3232
If want, you can [install](https://github.com/phpmetrics/PhpMetrics/blob/master/doc/installation.md) PhpMetrics globally with your favorite package manager. You can also visit our [documentation](http://www.phpmetrics.org/documentation/index.html).
3333

34+
## Metrics list
35+
36+
See the [metrics](doc/metrics.md) file.
37+
3438
## Author
3539

3640
+ Jean-François Lépine <[@Halleck45](https://twitter.com/Halleck45)>

doc/metrics.md

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# List of available metrics
2+
3+
## Halstead complexity measures
4+
### Metrics:
5+
length, vocabulary, volume, difficulty, effort, level, bugs, time, intelligentContent, number_operators, number_operands, number_operators_unique, number_operands_unique
6+
7+
### Description
8+
9+
**n1** = the number of distinct operators
10+
**n2** = the number of distinct operands
11+
**N1** = the total number of operators
12+
**N2** = the total number of operands
13+
14+
From these numbers, eight measures can be calculated:
15+
16+
**Program vocabulary:** n = n1 + n2
17+
**Program length:** N = N1 + N2
18+
**Calculated program length:** N' = n1 * log2(n1) + n2 * log2(n2)
19+
**Volume:** V = N * log2(n)
20+
**Difficulty:** D = (n1/2) * (N2/n2)
21+
**Effort:** E = D * V
22+
**Time required to program:** T = E / 18 seconds
23+
**Number of delivered bugs:** B = V / 3000
24+
25+
### Links
26+
[https://en.wikipedia.org/wiki/Halstead_complexity_measures](https://en.wikipedia.org/wiki/Halstead_complexity_measures)
27+
[https://www.verifysoft.com/en_halstead_metrics.html](https://www.verifysoft.com/en_halstead_metrics.html)
28+
29+
## Cyclomatic complexity number and weighted method count
30+
### Metrics:
31+
wmc, ccn, ccnMethodMax
32+
33+
### Description
34+
The cyclomatic complexity (CCN) is a measure of control structure complexity of a function or procedure.
35+
We can calculate ccn in two ways (we choose the second):
36+
37+
1. Cyclomatic complexity (CCN) = E - N + 2P
38+
Where:
39+
P = number of disconnected parts of the flow graph (e.g. a calling program and a subroutine)
40+
E = number of edges (transfers of control)
41+
N = number of nodes (sequential group of statements containing only one transfer of control)
42+
43+
2. CCN = Number of each decision point
44+
45+
The weighted method count (WMC) is count of methods parameterized by a algorithm to compute the weight of a method.
46+
Given a weight metric w and methods m it can be computed as
47+
48+
sum m(w') over (w' in w)
49+
50+
Possible algorithms are:
51+
52+
- Cyclomatic Complexity
53+
- Lines of Code
54+
- 1 (unweighted WMC)
55+
56+
This visitor provides two metrics, the maximal CCN of all methods from one class (currently stored as ccnMethodMax)
57+
and the WMC using the CCN as weight metric (currently stored as ccn).
58+
59+
### Links
60+
[https://en.wikipedia.org/wiki/Cyclomatic_complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity)
61+
[http://www.literateprogramming.com/mccabe.pdf](http://www.literateprogramming.com/mccabe.pdf)
62+
[https://www.pitt.edu/~ckemerer/CK%20research%20papers/MetricForOOD_ChidamberKemerer94.pdf](https://www.pitt.edu/~ckemerer/CK%20research%20papers/MetricForOOD_ChidamberKemerer94.pdf)
63+
64+
## Kan's defects
65+
### Metrics:
66+
kanDefect
67+
68+
### Description
69+
**kanDefect** = 0.15 + 0.23 * number of do…while() + 0.22 * number of switch() + 0.07 * number of if()
70+
71+
### Links
72+
73+
## Maintainability Index
74+
### Metrics:
75+
mi, mIwoC, commentWeight
76+
77+
### Description
78+
79+
According to Wikipedia, "Maintainability Index is a software metric which measures how maintainable (easy to support and change) the source code is. The maintainability index is calculated as a factored formula consisting of Lines Of Code, Cyclomatic Complexity and Halstead volume."
80+
81+
mIwoC: Maintainability Index without comments
82+
MIcw: Maintainability Index comment weight
83+
mi: Maintainability Index = MIwoc + MIcw
84+
85+
**MIwoc** = 171 - 5.2 * ln(aveV) -0.23 * aveG -16.2 * ln(aveLOC)
86+
**MIcw** = 50 * sin(sqrt(2.4 * perCM))
87+
**mi** = MIwoc + MIcw
88+
89+
### Links
90+
91+
[https://www.verifysoft.com/en_maintainability.html](https://www.verifysoft.com/en_maintainability.html)
92+
93+
94+
## Lack of cohesion of methods
95+
### Metrics:
96+
lcom
97+
98+
### Description
99+
100+
Cohesion metrics measure how well the methods of a class are related to each other. A cohesive class performs one function while a non-cohesive class performs two or more unrelated functions. A non-cohesive class may need to be restructured into two or more smaller classes.
101+
High cohesion is desirable since it promotes encapsulation. As a drawback, a highly cohesive class has high coupling between the methods of the class, which in turn indicates high testing effort for that class.
102+
Low cohesion indicates inappropriate design and high complexity. It has also been found to indicate a high likelihood of errors. The class should probably be split into two or more smaller classes.
103+
104+
### Links
105+
[https://blog.ndepend.com/lack-of-cohesion-methods/](https://blog.ndepend.com/lack-of-cohesion-methods/)
106+
[http://www.arisa.se/compendium/node116.html](http://www.arisa.se/compendium/node116.html)
107+
108+
## Card and Agresti metric
109+
### Metrics
110+
relativeStructuralComplexity, relativeDataComplexity, relativeSystemComplexity, totalStructuralComplexity, totalDataComplexity, totalSystemComplexity
111+
112+
### Description
113+
Fan-out = Structural fan-out = Number of other procedures this procedure calls
114+
115+
v = number of input/output variables for a procedure
116+
117+
(SC) Structural complexity = fan-out^2
118+
(DC) Data complexity = v / (fan-out + 1)
119+
120+
### Links
121+
[https://www.witpress.com/Secure/elibrary/papers/SQM94/SQM94024FU.pdf](https://www.witpress.com/Secure/elibrary/papers/SQM94/SQM94024FU.pdf)
122+
123+
## Length
124+
### Metrics:
125+
cloc, loc, lloc
126+
127+
### Description
128+
129+
**loc:** lines count
130+
**cloc:** lines count without multiline comments
131+
**lloc:** lines count without empty lines
132+
133+
### Links
134+
135+
## Methods
136+
### Metrics:
137+
nbMethodsIncludingGettersSetters, nbMethods, nbMethodsPrivate, nbMethodsPublic, nbMethodsGetter, nbMethodsSetters
138+
139+
## Coupling
140+
### Metrics:
141+
afferentCoupling, efferentCoupling, instability
142+
143+
### Description
144+
145+
**Afferent couplings (Ca):** The number of classes in other packages that depend upon classes within the package is an indicator of the package's responsibility.
146+
**Efferent couplings (Ce):** The number of classes in other packages that the classes in a package depend upon is an indicator of the package's dependence on externalities.
147+
**Instability (I):** The ratio of efferent coupling (Ce) to total coupling (Ce + Ca) such that I = Ce / (Ce + Ca).
148+
149+
### Links
150+
[https://www.future-processing.pl/blog/object-oriented-metrics-by-robert-martin/](https://www.future-processing.pl/blog/object-oriented-metrics-by-robert-martin/)
151+
[https://en.wikipedia.org/wiki/Software_package_metrics](https://en.wikipedia.org/wiki/Software_package_metrics)
152+
153+
## Depth of inheritance tree
154+
### Metrics:
155+
depthOfInheritanceTree
156+
157+
### Description
158+
Measures the length of inheritance from a class up to the root class.
159+
160+
### Links
161+
162+
## Page rank
163+
### Metrics:
164+
pageRank
165+
166+
### Description
167+
168+
### Links

0 commit comments

Comments
 (0)