@@ -8,7 +8,6 @@ |
||
8 | 8 | use PhpParser\Node\Stmt\Class_; |
9 | 9 | use PhpParser\Node\Stmt\Interface_; |
10 | 10 | use PhpParser\Node\Stmt\Namespace_; |
11 | -use PhpParser\Node\Stmt\Trait_; |
|
12 | 11 | use PhpParser\NodeVisitorAbstract; |
13 | 12 | |
14 | 13 | class PackageCollectingVisitor extends NodeVisitorAbstract |
@@ -42,11 +42,11 @@ |
||
42 | 42 | $package = $matches[1]; |
43 | 43 | } |
44 | 44 | if (preg_match('/^\s*\* @subpackage (.*)/m', $docBlockText, $matches)) { |
45 | - $package = $package . '\\' . $matches[1]; |
|
45 | + $package = $package.'\\'.$matches[1]; |
|
46 | 46 | } |
47 | 47 | |
48 | - $packageName = $package . '\\'; |
|
49 | - if (! $packageMetric = $this->metrics->get($packageName)) { |
|
48 | + $packageName = $package.'\\'; |
|
49 | + if (!$packageMetric = $this->metrics->get($packageName)) { |
|
50 | 50 | $packageMetric = new PackageMetric($packageName); |
51 | 51 | $this->metrics->attach($packageMetric); |
52 | 52 | } |
@@ -13,6 +13,9 @@ discard block |
||
13 | 13 | return $this->has('classes') ? $this->get('classes') : []; |
14 | 14 | } |
15 | 15 | |
16 | + /** |
|
17 | + * @param string $name |
|
18 | + */ |
|
16 | 19 | public function addClass($name) |
17 | 20 | { |
18 | 21 | $elements = $this->get('classes'); |
@@ -20,6 +23,9 @@ discard block |
||
20 | 23 | $this->set('classes', $elements); |
21 | 24 | } |
22 | 25 | |
26 | + /** |
|
27 | + * @param integer $abstraction |
|
28 | + */ |
|
23 | 29 | public function setAbstraction($abstraction) |
24 | 30 | { |
25 | 31 | $this->set('abstraction', $abstraction); |
@@ -30,6 +36,9 @@ discard block |
||
30 | 36 | return $this->get('abstraction'); |
31 | 37 | } |
32 | 38 | |
39 | + /** |
|
40 | + * @param integer $abstraction |
|
41 | + */ |
|
33 | 42 | public function setInstability($abstraction) |
34 | 43 | { |
35 | 44 | $this->set('instability', $abstraction); |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | } |
48 | 48 | $classDependencies = $this->getOutgoingClassDependencies(); |
49 | 49 | $packageDependencies = $this->getOutgoingPackageDependencies(); |
50 | - if (! in_array($className, $classDependencies)) { |
|
50 | + if (!in_array($className, $classDependencies)) { |
|
51 | 51 | $classDependencies[] = $className; |
52 | 52 | $this->set('outgoing_class_dependencies', $classDependencies); |
53 | 53 | } |
54 | - if (! in_array($packageName, $packageDependencies)) { |
|
54 | + if (!in_array($packageName, $packageDependencies)) { |
|
55 | 55 | $packageDependencies[] = $packageName; |
56 | 56 | $this->set('outgoing_package_dependencies', $packageDependencies); |
57 | 57 | } |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | } |
76 | 76 | $classDependencies = $this->getIncomingClassDependencies(); |
77 | 77 | $packageDependencies = $this->getIncomingPackageDependencies(); |
78 | - if (! in_array($className, $classDependencies)) { |
|
78 | + if (!in_array($className, $classDependencies)) { |
|
79 | 79 | $classDependencies[] = $className; |
80 | 80 | $this->set('incoming_class_dependencies', $classDependencies); |
81 | 81 | } |
82 | - if (! in_array($packageName, $packageDependencies)) { |
|
82 | + if (!in_array($packageName, $packageDependencies)) { |
|
83 | 83 | $packageDependencies[] = $packageName; |
84 | 84 | $this->set('incoming_package_dependencies', $packageDependencies); |
85 | 85 | } |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | |
22 | 22 | public function apply(Metric $metric) |
23 | 23 | { |
24 | - if (! $metric instanceof PackageMetric) { |
|
24 | + if (!$metric instanceof PackageMetric) { |
|
25 | 25 | return; |
26 | 26 | } |
27 | 27 | $instability = $metric->getInstability(); |
28 | 28 | $violatingInstabilities = array_filter( |
29 | 29 | $metric->getDependentInstabilities(), |
30 | - function ($otherInstability) use ($instability) { |
|
30 | + function($otherInstability) use ($instability) { |
|
31 | 31 | return $otherInstability >= $instability; |
32 | 32 | } |
33 | 33 | ); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | { |
48 | 48 | $count = count($this->violatingInstabilities); |
49 | 49 | $thisInstability = round($this->metric->getInstability(), 3); |
50 | - $packages = implode("\n* ", array_map(function ($name, $instability) { |
|
50 | + $packages = implode("\n* ", array_map(function($name, $instability) { |
|
51 | 51 | $name = $name === '\\' ? 'global' : substr($name, 0, -1); |
52 | 52 | $instability = round($instability, 3); |
53 | 53 | return "$name ($instability)"; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | </div> |
2 | 2 | |
3 | 3 | <!-- Sidebar --> |
4 | -<?php if(!isset($fullwidth) || $fullwidth === false) {?> |
|
4 | +<?php if (!isset($fullwidth) || $fullwidth === false) {?> |
|
5 | 5 | <div id="sidebar"> |
6 | 6 | <div class="content"> |
7 | 7 | <div class="logo"> |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | <path d="M0 0h24v24H0z" fill="none"/> |
29 | 29 | <path d="M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"/> |
30 | 30 | </svg> |
31 | - Violations (<?php echo $sum->violations->total;?>) |
|
31 | + Violations (<?php echo $sum->violations->total; ?>) |
|
32 | 32 | </a> |
33 | 33 | </li> |
34 | - <?php if($config->has('junit')) { ?> |
|
34 | + <?php if ($config->has('junit')) { ?> |
|
35 | 35 | <li> |
36 | 36 | <a href="junit.html"> |
37 | 37 | <svg fill="#FFFFFF" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"> |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | Package relations |
126 | 126 | </a> |
127 | 127 | </li> |
128 | - <?php if($config->has('git')) { ?> |
|
128 | + <?php if ($config->has('git')) { ?> |
|
129 | 129 | <li> |
130 | 130 | <a href="git.html"> |
131 | 131 | <img src="images/logo-git.png" alt=""> |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -require __DIR__ . '/_header.php'; ?> |
|
2 | +require __DIR__.'/_header.php'; ?> |
|
3 | 3 | |
4 | 4 | <div class="row"> |
5 | 5 | <div class="column"> |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | </div> |
41 | 41 | </div> |
42 | 42 | </div> |
43 | -<?php require __DIR__ . '/_footer.php'; ?> |
|
43 | +<?php require __DIR__.'/_footer.php'; ?> |
|
44 | 44 | <?php |
45 | 45 | $spots = []; |
46 | 46 | foreach ($packages as $each) { |
@@ -1,8 +1,8 @@ discard block |
||
1 | -<?php require __DIR__ . '/_header.php'; ?> |
|
1 | +<?php require __DIR__.'/_header.php'; ?> |
|
2 | 2 | |
3 | 3 | <?php |
4 | 4 | $relations = []; |
5 | -$getPackageName = function ($name) { |
|
5 | +$getPackageName = function($name) { |
|
6 | 6 | return $name === '\\' ? 'global' : substr($name, 0, -1); |
7 | 7 | }; |
8 | 8 | foreach ($packages as $package) { |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | </div> |
42 | 42 | </div> |
43 | 43 | |
44 | -<?php require __DIR__ . '/_footer.php'; ?> |
|
44 | +<?php require __DIR__.'/_footer.php'; ?> |
|
45 | 45 | |
46 | 46 | |
47 | 47 | <script type="text/javascript"> |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php require __DIR__ . '/_header.php'; ?> |
|
1 | +<?php require __DIR__.'/_header.php'; ?> |
|
2 | 2 | |
3 | 3 | <?php |
4 | 4 | $map = [ |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | <tbody> |
58 | 58 | <?php foreach ($classes as $class) { |
59 | 59 | if (sizeof($class['violations']) > 0) { |
60 | - $currentId = 'bloc-' . uniqid(); |
|
60 | + $currentId = 'bloc-'.uniqid(); |
|
61 | 61 | ?> |
62 | 62 | |
63 | 63 | <tr> |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | <tbody> |
109 | 109 | <?php foreach ($packages as $package) { |
110 | 110 | if (sizeof($package['violations']) > 0) { |
111 | - $currentId = 'bloc-' . uniqid(); |
|
111 | + $currentId = 'bloc-'.uniqid(); |
|
112 | 112 | ?> |
113 | 113 | |
114 | 114 | <tr> |
@@ -158,4 +158,4 @@ discard block |
||
158 | 158 | } |
159 | 159 | } |
160 | 160 | </script> |
161 | -<?php require __DIR__ . '/_footer.php'; ?> |
|
162 | 161 | \ No newline at end of file |
162 | +<?php require __DIR__.'/_footer.php'; ?> |
|
163 | 163 | \ No newline at end of file |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | $consolidated = new Consolidated($metrics); |
45 | 45 | |
46 | 46 | // history of builds |
47 | - $today = (object)[ |
|
47 | + $today = (object) [ |
|
48 | 48 | 'avg' => $consolidated->getAvg(), |
49 | 49 | 'sum' => $consolidated->getSum() |
50 | 50 | ]; |
51 | - $files = glob($logDir . '/js/history-*.json'); |
|
51 | + $files = glob($logDir.'/js/history-*.json'); |
|
52 | 52 | $next = sizeof($files) + 1; |
53 | 53 | $history = []; |
54 | 54 | natsort($files); |
@@ -57,35 +57,35 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | // copy sources |
60 | - if(!file_exists($logDir . '/js')) { |
|
60 | + if (!file_exists($logDir.'/js')) { |
|
61 | 61 | mkdir($logDir.'/js', 0755, true); |
62 | 62 | } |
63 | - if(!file_exists($logDir . '/css')) { |
|
63 | + if (!file_exists($logDir.'/css')) { |
|
64 | 64 | mkdir($logDir.'/css', 0755, true); |
65 | 65 | } |
66 | - if(!file_exists($logDir . '/images')) { |
|
66 | + if (!file_exists($logDir.'/images')) { |
|
67 | 67 | mkdir($logDir.'/images', 0755, true); |
68 | 68 | } |
69 | - recurse_copy(__DIR__ . '/template/js', $logDir . '/js'); |
|
70 | - recurse_copy(__DIR__ . '/template/css', $logDir . '/css'); |
|
71 | - recurse_copy(__DIR__ . '/template/images', $logDir . '/images'); |
|
69 | + recurse_copy(__DIR__.'/template/js', $logDir.'/js'); |
|
70 | + recurse_copy(__DIR__.'/template/css', $logDir.'/css'); |
|
71 | + recurse_copy(__DIR__.'/template/images', $logDir.'/images'); |
|
72 | 72 | |
73 | 73 | // render dynamic pages |
74 | - $this->renderPage(__DIR__ . '/template/index.php', $logDir . '/index.html', $consolidated, $history); |
|
75 | - $this->renderPage(__DIR__ . '/template/loc.php', $logDir . '/loc.html', $consolidated, $history); |
|
76 | - $this->renderPage(__DIR__ . '/template/relations.php', $logDir . '/relations.html', $consolidated, $history); |
|
77 | - $this->renderPage(__DIR__ . '/template/coupling.php', $logDir . '/coupling.html', $consolidated, $history); |
|
78 | - $this->renderPage(__DIR__ . '/template/all.php', $logDir . '/all.html', $consolidated, $history); |
|
79 | - $this->renderPage(__DIR__ . '/template/oop.php', $logDir . '/oop.html', $consolidated, $history); |
|
80 | - $this->renderPage(__DIR__ . '/template/complexity.php', $logDir . '/complexity.html', $consolidated, $history); |
|
81 | - $this->renderPage(__DIR__ . '/template/panel.php', $logDir . '/panel.html', $consolidated, $history); |
|
82 | - $this->renderPage(__DIR__ . '/template/violations.php', $logDir . '/violations.html', $consolidated, $history); |
|
83 | - $this->renderPage(__DIR__ . '/template/packages.php', $logDir . '/packages.html', $consolidated, $history); |
|
84 | - $this->renderPage(__DIR__ . '/template/package_relations.php', $logDir . '/package_relations.html', $consolidated, $history); |
|
74 | + $this->renderPage(__DIR__.'/template/index.php', $logDir.'/index.html', $consolidated, $history); |
|
75 | + $this->renderPage(__DIR__.'/template/loc.php', $logDir.'/loc.html', $consolidated, $history); |
|
76 | + $this->renderPage(__DIR__.'/template/relations.php', $logDir.'/relations.html', $consolidated, $history); |
|
77 | + $this->renderPage(__DIR__.'/template/coupling.php', $logDir.'/coupling.html', $consolidated, $history); |
|
78 | + $this->renderPage(__DIR__.'/template/all.php', $logDir.'/all.html', $consolidated, $history); |
|
79 | + $this->renderPage(__DIR__.'/template/oop.php', $logDir.'/oop.html', $consolidated, $history); |
|
80 | + $this->renderPage(__DIR__.'/template/complexity.php', $logDir.'/complexity.html', $consolidated, $history); |
|
81 | + $this->renderPage(__DIR__.'/template/panel.php', $logDir.'/panel.html', $consolidated, $history); |
|
82 | + $this->renderPage(__DIR__.'/template/violations.php', $logDir.'/violations.html', $consolidated, $history); |
|
83 | + $this->renderPage(__DIR__.'/template/packages.php', $logDir.'/packages.html', $consolidated, $history); |
|
84 | + $this->renderPage(__DIR__.'/template/package_relations.php', $logDir.'/package_relations.html', $consolidated, $history); |
|
85 | 85 | if ($this->config->has('git')) { |
86 | - $this->renderPage(__DIR__ . '/template/git.php', $logDir . '/git.html', $consolidated, $history); |
|
86 | + $this->renderPage(__DIR__.'/template/git.php', $logDir.'/git.html', $consolidated, $history); |
|
87 | 87 | } |
88 | - $this->renderPage(__DIR__ . '/template/junit.php', $logDir . '/junit.html', $consolidated, $history); |
|
88 | + $this->renderPage(__DIR__.'/template/junit.php', $logDir.'/junit.html', $consolidated, $history); |
|
89 | 89 | |
90 | 90 | // js data |
91 | 91 | file_put_contents( |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | |
100 | 100 | // json data |
101 | 101 | file_put_contents( |
102 | - $logDir . '/js/classes.js', |
|
103 | - 'var classes = ' . json_encode($consolidated->getClasses(), JSON_PRETTY_PRINT) |
|
102 | + $logDir.'/js/classes.js', |
|
103 | + 'var classes = '.json_encode($consolidated->getClasses(), JSON_PRETTY_PRINT) |
|
104 | 104 | ); |
105 | 105 | |
106 | 106 | $this->output->writeln(sprintf('HTML report generated in "%s" directory', $logDir)); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | $diff = $newValue - $oldValue; |
171 | 171 | if ($diff > 0) { |
172 | - $diff = '+' . $diff; |
|
172 | + $diff = '+'.$diff; |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | $goodOrBad = 'neutral'; |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | $class->set('abstract', true); |
40 | 40 | } else { |
41 | 41 | |
42 | - if(null === $node->name) { |
|
42 | + if (null === $node->name) { |
|
43 | 43 | // anonymous class |
44 | - $name = 'anonymous@' . spl_object_hash($node); |
|
44 | + $name = 'anonymous@'.spl_object_hash($node); |
|
45 | 45 | } else { |
46 | 46 | $name = $node->namespacedName->toString(); |
47 | 47 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | $class->set('methods', $methods); |
93 | - $class->set('nbMethodsIncludingGettersSetters', sizeof($methods) ); |
|
93 | + $class->set('nbMethodsIncludingGettersSetters', sizeof($methods)); |
|
94 | 94 | $class->set('nbMethods', sizeof($methods) - ($nbGetters + $nbSetters)); |
95 | 95 | $class->set('nbMethodsPrivate', $methodsPrivate); |
96 | 96 | $class->set('nbMethodsPublic', $methodsPublic); |