@@ -49,7 +49,7 @@ |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | - * @param $key |
|
52 | + * @param string $key |
|
53 | 53 | * @return null |
54 | 54 | */ |
55 | 55 | public function get($key) |
@@ -1,7 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Hal\Metric\Class_; |
3 | 3 | |
4 | -use Hal\Component\Reflected\Method; |
|
5 | 4 | use Hal\Metric\ClassMetric; |
6 | 5 | use Hal\Metric\FunctionMetric; |
7 | 6 | use Hal\Metric\Helper\RoleOfMethodDetector; |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | $class->set('interface', true); |
41 | 41 | } else { |
42 | 42 | |
43 | - if(null === $node->name) { |
|
43 | + if (null === $node->name) { |
|
44 | 44 | // anonymous class |
45 | - $name = 'anonymous@' . spl_object_hash($node); |
|
45 | + $name = 'anonymous@'.spl_object_hash($node); |
|
46 | 46 | } else { |
47 | 47 | $name = $node->namespacedName->toString(); |
48 | 48 | } |
@@ -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); |
@@ -3,7 +3,6 @@ |
||
3 | 3 | |
4 | 4 | use Hal\Metric\FunctionMetric; |
5 | 5 | use Hal\Metric\Metrics; |
6 | -use Hoa\Ruler\Model\Bag\Scalar; |
|
7 | 6 | use PhpParser\Node; |
8 | 7 | use PhpParser\Node\Stmt; |
9 | 8 | use PhpParser\NodeVisitorAbstract; |
@@ -109,8 +109,8 @@ |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
112 | - * @param $source |
|
113 | - * @param $destination |
|
112 | + * @param string $source |
|
113 | + * @param string $destination |
|
114 | 114 | * @return $this |
115 | 115 | */ |
116 | 116 | public function renderPage($source, $destination, Consolidated $consolidated, $history) |
@@ -92,7 +92,7 @@ |
||
92 | 92 | sprintf('%s/js/history-%d.json', $logDir, $next), |
93 | 93 | json_encode($today, JSON_PRETTY_PRINT) |
94 | 94 | ); |
95 | - file_put_contents( |
|
95 | + file_put_contents( |
|
96 | 96 | sprintf('%s/js/latest.json', $logDir, $next), |
97 | 97 | json_encode($today, JSON_PRETTY_PRINT) |
98 | 98 | ); |
@@ -4,7 +4,6 @@ |
||
4 | 4 | use Hal\Application\Config\Config; |
5 | 5 | use Hal\Component\Output\Output; |
6 | 6 | use Hal\Metric\Consolidated; |
7 | -use Hal\Metric\Consolided; |
|
8 | 7 | use Hal\Metric\Metrics; |
9 | 8 | |
10 | 9 | class Reporter |
@@ -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,33 +57,33 @@ 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); |
|
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 | 83 | if ($this->config->has('git')) { |
84 | - $this->renderPage(__DIR__ . '/template/git.php', $logDir . '/git.html', $consolidated, $history); |
|
84 | + $this->renderPage(__DIR__.'/template/git.php', $logDir.'/git.html', $consolidated, $history); |
|
85 | 85 | } |
86 | - $this->renderPage(__DIR__ . '/template/junit.php', $logDir . '/junit.html', $consolidated, $history); |
|
86 | + $this->renderPage(__DIR__.'/template/junit.php', $logDir.'/junit.html', $consolidated, $history); |
|
87 | 87 | |
88 | 88 | // js data |
89 | 89 | file_put_contents( |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | |
98 | 98 | // json data |
99 | 99 | file_put_contents( |
100 | - $logDir . '/js/classes.js', |
|
101 | - 'var classes = ' . json_encode($consolidated->getClasses(), JSON_PRETTY_PRINT) |
|
100 | + $logDir.'/js/classes.js', |
|
101 | + 'var classes = '.json_encode($consolidated->getClasses(), JSON_PRETTY_PRINT) |
|
102 | 102 | ); |
103 | 103 | |
104 | 104 | $this->output->writeln(sprintf('HTML report generated in "%s" directory', $logDir)); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | $diff = $newValue - $oldValue; |
168 | 168 | if ($diff > 0) { |
169 | - $diff = '+' . $diff; |
|
169 | + $diff = '+'.$diff; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | $goodOrBad = 'neutral'; |
@@ -44,7 +44,7 @@ |
||
44 | 44 | { |
45 | 45 | $string = ''; |
46 | 46 | foreach ($this->data as $violation) { |
47 | - $string .= $violation->getName() . ','; |
|
47 | + $string .= $violation->getName().','; |
|
48 | 48 | } |
49 | 49 | return $string; |
50 | 50 | } |
@@ -58,7 +58,7 @@ |
||
58 | 58 | // analyze |
59 | 59 | try { |
60 | 60 | $metrics = (new Analyze($config, $output, $issuer))->run($files); |
61 | - }catch(ConfigException $e) { |
|
61 | + } catch(ConfigException $e) { |
|
62 | 62 | $output->writeln(sprintf('<error>%s</error>', $e->getMessage())); |
63 | 63 | exit(1); |
64 | 64 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | $output = new CliOutput(); |
24 | 24 | |
25 | 25 | // issues and debug |
26 | - $issuer = (new Issuer($output));//->enable(); |
|
26 | + $issuer = (new Issuer($output)); //->enable(); |
|
27 | 27 | |
28 | 28 | // config |
29 | 29 | $config = (new Parser())->parse($argv); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | // analyze |
58 | 58 | try { |
59 | 59 | $metrics = (new Analyze($config, $output, $issuer))->run($files); |
60 | - }catch(ConfigException $e) { |
|
60 | + } catch (ConfigException $e) { |
|
61 | 61 | $output->writeln(sprintf('<error>%s</error>', $e->getMessage())); |
62 | 62 | exit(1); |
63 | 63 | } |
@@ -25,9 +25,9 @@ |
||
25 | 25 | { |
26 | 26 | parent::__construct($cloneNodes); |
27 | 27 | |
28 | - if(null === $stopCondition) { |
|
28 | + if (null === $stopCondition) { |
|
29 | 29 | $stopCondition = function($node) { |
30 | - if($node instanceof Node\Stmt\Class_ || $node instanceof Node\Stmt\Interface_) { |
|
30 | + if ($node instanceof Node\Stmt\Class_ || $node instanceof Node\Stmt\Interface_) { |
|
31 | 31 | return false; |
32 | 32 | } |
33 | 33 |
@@ -21,6 +21,9 @@ |
||
21 | 21 | { |
22 | 22 | protected $stopCondition; |
23 | 23 | |
24 | + /** |
|
25 | + * @param \Closure $stopCondition |
|
26 | + */ |
|
24 | 27 | public function __construct($cloneNodes = false, $stopCondition = null) |
25 | 28 | { |
26 | 29 | parent::__construct($cloneNodes); |
@@ -71,14 +71,14 @@ |
||
71 | 71 | $files = array(); |
72 | 72 | foreach ($paths as $path) { |
73 | 73 | if (is_dir($path)) { |
74 | - $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
74 | + $path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; |
|
75 | 75 | $directory = new RecursiveDirectoryIterator($path, $this->flags); |
76 | 76 | $iterator = new RecursiveIteratorIterator($directory); |
77 | 77 | |
78 | 78 | $filterRegex = sprintf( |
79 | 79 | '`^%s%s$`', |
80 | - !empty($this->excludedDirs) ? '((?!' . implode('|', $this->excludedDirs) . ').)+' : '.+', |
|
81 | - '\.(' . implode('|', $this->extensions) . ')' |
|
80 | + !empty($this->excludedDirs) ? '((?!'.implode('|', $this->excludedDirs).').)+' : '.+', |
|
81 | + '\.('.implode('|', $this->extensions).')' |
|
82 | 82 | ); |
83 | 83 | |
84 | 84 | $filteredIterator = new RegexIterator( |
@@ -1,17 +1,17 @@ discard block |
||
1 | -<?php require __DIR__ . '/_header.php'; ?> |
|
1 | +<?php require __DIR__.'/_header.php'; ?> |
|
2 | 2 | |
3 | 3 | <?php |
4 | 4 | $relations = []; |
5 | 5 | $classesCp = []; |
6 | 6 | foreach ($classes as $class) { |
7 | 7 | |
8 | - $class['name'] = '\\' . $class['name']; |
|
8 | + $class['name'] = '\\'.$class['name']; |
|
9 | 9 | $classesCp[$class['name']] = $class; |
10 | 10 | $classesCp[$class['name']]['externals'] = []; |
11 | 11 | |
12 | 12 | |
13 | 13 | foreach ($class['externals'] as &$ext) { |
14 | - $ext = '\\' . $ext; |
|
14 | + $ext = '\\'.$ext; |
|
15 | 15 | if (!isset($classes[$ext])) { |
16 | 16 | $classesCp[$ext] = [ |
17 | 17 | 'name' => $ext, |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | } |
23 | 23 | } |
24 | 24 | foreach ($classesCp as $class) { |
25 | - array_push($relations, (object)[ |
|
25 | + array_push($relations, (object) [ |
|
26 | 26 | 'name' => $class['name'], |
27 | 27 | 'size' => 3000, |
28 | - 'relations' => (array)array_values(array_unique($class['externals'])), |
|
28 | + 'relations' => (array) array_values(array_unique($class['externals'])), |
|
29 | 29 | ]); |
30 | 30 | } |
31 | 31 | ?> |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | </div> |
41 | 41 | </div> |
42 | 42 | |
43 | -<?php require __DIR__ . '/_footer.php'; ?> |
|
43 | +<?php require __DIR__.'/_footer.php'; ?> |
|
44 | 44 | |
45 | 45 | |
46 | 46 | <script type="text/javascript"> |