Skip to content

Commit

Permalink
Add cli output
Browse files Browse the repository at this point in the history
  • Loading branch information
UFOMelkor committed Oct 26, 2017
1 parent ddd5835 commit 41c3a33
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Hal/Metric/Consolidated.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public function __construct(Metrics $metrics)
}
$sum->nbClasses = count($classes);
$sum->nbInterfaces = $nbInterfaces;
$sum->nbPackages = count($packages);

foreach ($avg as &$a) {
if (sizeof($a) > 0) {
Expand All @@ -112,6 +113,29 @@ public function __construct(Metrics $metrics)
}
}

$avg->distance = 0;
$avg->incomingCDep = 0;
$avg->incomingPDep = 0;
$avg->outgoingCDep = 0;
$avg->outgoingPDep = 0;
$avg->classesPerPackage = 0;
foreach (array_keys($packages) as $eachName) {
/* @var $eachPackage PackageMetric */
$eachPackage = $metrics->get($eachName);
$avg->distance += $eachPackage->getDistance();
$avg->incomingCDep += count($eachPackage->getIncomingClassDependencies());
$avg->incomingPDep += count($eachPackage->getIncomingPackageDependencies());
$avg->outgoingCDep += count($eachPackage->getOutgoingClassDependencies());
$avg->outgoingPDep += count($eachPackage->getOutgoingPackageDependencies());
$avg->classesPerPackage += count($eachPackage->getClasses());
}
$avg->distance = round($avg->distance / count($packages), 2);
$avg->incomingCDep = round($avg->incomingCDep / count($packages), 2);
$avg->incomingPDep = round($avg->incomingPDep / count($packages), 2);
$avg->outgoingCDep = round($avg->outgoingCDep / count($packages), 2);
$avg->outgoingPDep = round($avg->outgoingPDep / count($packages), 2);
$avg->classesPerPackage = round($avg->classesPerPackage / count($packages), 2);

// sums of violations
$violations = [
'total' => 0,
Expand Down
9 changes: 9 additions & 0 deletions src/Hal/Report/Cli/Reporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ public function generate(Metrics $metrics)
Average efferent coupling {$avg->efferentCoupling}
Average instability {$avg->instability}
Depth of Inheritance Tree {$metrics->get('tree')->get('depthOfInheritanceTree')}
Package
Packages {$sum->nbPackages}
Average classes per package {$avg->classesPerPackage}
Average distance {$avg->distance}
Average incoming class dependencies {$avg->incomingCDep}
Average outgoing class dependencies {$avg->outgoingCDep}
Average incoming package dependencies {$avg->incomingPDep}
Average outgoing package dependencies {$avg->outgoingPDep}
Complexity
Average Cyclomatic complexity by class {$avg->ccn}
Expand Down

0 comments on commit 41c3a33

Please sign in to comment.