@@ -29,109 +29,14 @@ public function __construct(Config $config, Output $output)
2929 $ this ->output = $ output ;
3030 }
3131
32-
3332 public function generate (Metrics $ metrics )
3433 {
3534 if ($ this ->config ->has ('quiet ' )) {
3635 return ;
3736 }
3837
39- // grouping results
40- $ consolidated = new Consolidated ($ metrics );
41- $ sum = $ consolidated ->getSum ();
42- $ avg = $ consolidated ->getAvg ();
43-
44- $ methodsByClass = $ locByClass = $ locByMethod = 0 ;
45- if ($ sum ->nbClasses > 0 ) {
46- $ methodsByClass = round ($ sum ->nbMethods / $ sum ->nbClasses , 2 );
47- $ locByClass = round ($ sum ->lloc / $ sum ->nbClasses );
48- }
49- if ($ sum ->nbMethods > 0 ) {
50- $ locByMethod = round ($ sum ->lloc / $ sum ->nbMethods );
51- }
52-
53- $ out = <<<EOT
54- LOC
55- Lines of code {$ sum ->loc }
56- Logical lines of code {$ sum ->lloc }
57- Comment lines of code {$ sum ->cloc }
58- Average volume {$ avg ->volume }
59- Average comment weight {$ avg ->commentWeight }
60- Average intelligent content {$ avg ->commentWeight }
61- Logical lines of code by class {$ locByClass }
62- Logical lines of code by method {$ locByMethod }
63-
64- Object oriented programming
65- Classes {$ sum ->nbClasses }
66- Interface {$ sum ->nbInterfaces }
67- Methods {$ sum ->nbMethods }
68- Methods by class {$ methodsByClass }
69- Lack of cohesion of methods {$ avg ->lcom }
70-
71- Coupling
72- Average afferent coupling {$ avg ->afferentCoupling }
73- Average efferent coupling {$ avg ->efferentCoupling }
74- Average instability {$ avg ->instability }
75- Depth of Inheritance Tree {$ metrics ->get ('tree ' )->get ('depthOfInheritanceTree ' )}
76-
77- Package
78- Packages {$ sum ->nbPackages }
79- Average classes per package {$ avg ->classesPerPackage }
80- Average distance {$ avg ->distance }
81- Average incoming class dependencies {$ avg ->incomingCDep }
82- Average outgoing class dependencies {$ avg ->outgoingCDep }
83- Average incoming package dependencies {$ avg ->incomingPDep }
84- Average outgoing package dependencies {$ avg ->outgoingPDep }
85-
86- Complexity
87- Average Cyclomatic complexity by class {$ avg ->ccn }
88- Average Weighted method count by class {$ avg ->wmc }
89- Average Relative system complexity {$ avg ->relativeSystemComplexity }
90- Average Difficulty {$ avg ->difficulty }
91-
92- Bugs
93- Average bugs by class {$ avg ->bugs }
94- Average defects by class (Kan) {$ avg ->kanDefect }
95-
96- Violations
97- Critical {$ sum ->violations ->critical }
98- Error {$ sum ->violations ->error }
99- Warning {$ sum ->violations ->warning }
100- Information {$ sum ->violations ->information }
101-
102- EOT ;
103-
104- // git
105- if ($ this ->config ->has ('git ' )) {
106- $ commits = [];
107- foreach ($ consolidated ->getFiles () as $ name => $ file ) {
108- $ commits [$ name ] = $ file ['gitChanges ' ];
109- }
110- arsort ($ commits );
111- $ commits = array_slice ($ commits , 0 , 10 );
112-
113- $ out .= "\nTop 10 committed files " ;
114- foreach ($ commits as $ file => $ nb ) {
115- $ out .= sprintf ("\n %d %s " , $ nb , $ file );
116- }
117- if (0 === count ($ commits )) {
118- $ out .= "\n NA " ;
119- }
120- $ out .= "\n" ;
121- }
122-
123- // Junit
124- if ($ this ->config ->has ('junit ' )) {
125- $ out .= <<<EOT
126-
127- Unit testing
128- Number of unit tests {$ metrics ->get ('unitTesting ' )->get ('nbSuites ' )}
129- Classes called by tests {$ metrics ->get ('unitTesting ' )->get ('nbCoveredClasses ' )}
130- Classes called by tests (percent) {$ metrics ->get ('unitTesting ' )->get ('percentCoveredClasses ' )} %
131- EOT ;
132- }
133-
134- $ out .= "\n\n" ;
135- $ this ->output ->write ($ out );
38+ $ this ->output ->write (
39+ (new SummaryWriter ($ metrics , new Consolidated ($ metrics ), $ this ->config ))->getReport ()
40+ );
13641 }
13742}
0 commit comments