@@ -14,7 +14,7 @@ |
||
14 | 14 | // With nikic/php-parser >= v5, visitors are traversed in LIFO order. |
15 | 15 | // With nikic/php-parser < v5, visitors are traversed in FIFO order. |
16 | 16 | |
17 | - if (! method_exists('PhpParser\ParserFactory', 'create')) { |
|
17 | + if (!method_exists('PhpParser\ParserFactory', 'create')) { |
|
18 | 18 | $visitors = array_reverse($visitors); |
19 | 19 | } |
20 | 20 |
@@ -10,7 +10,7 @@ |
||
10 | 10 | public function create($kind = null) |
11 | 11 | { |
12 | 12 | if (!method_exists('PhpParser\ParserFactory', 'createForNewestSupportedVersion')) { |
13 | - if(null === $kind) { |
|
13 | + if (null === $kind) { |
|
14 | 14 | $kind = \PhpParser\ParserFactory::PREFER_PHP7; |
15 | 15 | } |
16 | 16 | return (new \PhpParser\ParserFactory())->create($kind); |
@@ -18,7 +18,7 @@ |
||
18 | 18 | |
19 | 19 | public function apply(Metric $metric) |
20 | 20 | { |
21 | - if (! $metric instanceof PackageMetric) { |
|
21 | + if (!$metric instanceof PackageMetric) { |
|
22 | 22 | return; |
23 | 23 | } |
24 | 24 | if (abs($metric->getDistance()) > sqrt(2) / 4) { |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | { |
55 | 55 | $this->config = $config; |
56 | 56 | $this->output = $output; |
57 | - $this->templateDir = __DIR__ . '/../../../../templates'; |
|
57 | + $this->templateDir = __DIR__.'/../../../../templates'; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | 'avg' => $consolidated->getAvg(), |
84 | 84 | 'sum' => $consolidated->getSum(), |
85 | 85 | ]; |
86 | - $files = glob($logDir . '/js/history-*.json'); |
|
86 | + $files = glob($logDir.'/js/history-*.json'); |
|
87 | 87 | $next = count($files) + 1; |
88 | 88 | $history = []; |
89 | 89 | natsort($files); |
@@ -92,47 +92,47 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | // copy sources |
95 | - if (!file_exists($logDir . '/js')) { |
|
96 | - mkdir($logDir . '/js', 0755, true); |
|
95 | + if (!file_exists($logDir.'/js')) { |
|
96 | + mkdir($logDir.'/js', 0755, true); |
|
97 | 97 | } |
98 | - if (!file_exists($logDir . '/css')) { |
|
99 | - mkdir($logDir . '/css', 0755, true); |
|
98 | + if (!file_exists($logDir.'/css')) { |
|
99 | + mkdir($logDir.'/css', 0755, true); |
|
100 | 100 | } |
101 | - if (!file_exists($logDir . '/images')) { |
|
102 | - mkdir($logDir . '/images', 0755, true); |
|
101 | + if (!file_exists($logDir.'/images')) { |
|
102 | + mkdir($logDir.'/images', 0755, true); |
|
103 | 103 | } |
104 | - if (!file_exists($logDir . '/fonts')) { |
|
105 | - mkdir($logDir . '/fonts', 0755, true); |
|
104 | + if (!file_exists($logDir.'/fonts')) { |
|
105 | + mkdir($logDir.'/fonts', 0755, true); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | if (!is_writable($logDir)) { |
109 | 109 | throw new RuntimeExceptionAlias(sprintf('Unable to write in the directory "%s"', $logDir)); |
110 | 110 | } |
111 | 111 | |
112 | - copy($this->templateDir . '/html_report/favicon.ico', $logDir . '/favicon.ico'); |
|
112 | + copy($this->templateDir.'/html_report/favicon.ico', $logDir.'/favicon.ico'); |
|
113 | 113 | |
114 | - recurse_copy($this->templateDir . '/html_report/js', $logDir . '/js'); |
|
115 | - recurse_copy($this->templateDir . '/html_report/css', $logDir . '/css'); |
|
116 | - recurse_copy($this->templateDir . '/html_report/images', $logDir . '/images'); |
|
117 | - recurse_copy($this->templateDir . '/html_report/fonts', $logDir . '/fonts'); |
|
114 | + recurse_copy($this->templateDir.'/html_report/js', $logDir.'/js'); |
|
115 | + recurse_copy($this->templateDir.'/html_report/css', $logDir.'/css'); |
|
116 | + recurse_copy($this->templateDir.'/html_report/images', $logDir.'/images'); |
|
117 | + recurse_copy($this->templateDir.'/html_report/fonts', $logDir.'/fonts'); |
|
118 | 118 | |
119 | 119 | // render dynamic pages |
120 | - $this->renderPage($this->templateDir . '/html_report/index.php', $logDir . '/index.html', $consolidated, $history); |
|
121 | - $this->renderPage($this->templateDir . '/html_report/loc.php', $logDir . '/loc.html', $consolidated, $history); |
|
122 | - $this->renderPage($this->templateDir . '/html_report/relations.php', $logDir . '/relations.html', $consolidated, $history); |
|
123 | - $this->renderPage($this->templateDir . '/html_report/coupling.php', $logDir . '/coupling.html', $consolidated, $history); |
|
124 | - $this->renderPage($this->templateDir . '/html_report/all.php', $logDir . '/all.html', $consolidated, $history); |
|
125 | - $this->renderPage($this->templateDir . '/html_report/oop.php', $logDir . '/oop.html', $consolidated, $history); |
|
126 | - $this->renderPage($this->templateDir . '/html_report/complexity.php', $logDir . '/complexity.html', $consolidated, $history); |
|
127 | - $this->renderPage($this->templateDir . '/html_report/panel.php', $logDir . '/panel.html', $consolidated, $history); |
|
128 | - $this->renderPage($this->templateDir . '/html_report/violations.php', $logDir . '/violations.html', $consolidated, $history); |
|
129 | - $this->renderPage($this->templateDir . '/html_report/packages.php', $logDir . '/packages.html', $consolidated, $history); |
|
130 | - $this->renderPage($this->templateDir . '/html_report/package_relations.php', $logDir . '/package_relations.html', $consolidated, $history); |
|
131 | - $this->renderPage($this->templateDir . '/html_report/composer.php', $logDir . '/composer.html', $consolidated, $history); |
|
120 | + $this->renderPage($this->templateDir.'/html_report/index.php', $logDir.'/index.html', $consolidated, $history); |
|
121 | + $this->renderPage($this->templateDir.'/html_report/loc.php', $logDir.'/loc.html', $consolidated, $history); |
|
122 | + $this->renderPage($this->templateDir.'/html_report/relations.php', $logDir.'/relations.html', $consolidated, $history); |
|
123 | + $this->renderPage($this->templateDir.'/html_report/coupling.php', $logDir.'/coupling.html', $consolidated, $history); |
|
124 | + $this->renderPage($this->templateDir.'/html_report/all.php', $logDir.'/all.html', $consolidated, $history); |
|
125 | + $this->renderPage($this->templateDir.'/html_report/oop.php', $logDir.'/oop.html', $consolidated, $history); |
|
126 | + $this->renderPage($this->templateDir.'/html_report/complexity.php', $logDir.'/complexity.html', $consolidated, $history); |
|
127 | + $this->renderPage($this->templateDir.'/html_report/panel.php', $logDir.'/panel.html', $consolidated, $history); |
|
128 | + $this->renderPage($this->templateDir.'/html_report/violations.php', $logDir.'/violations.html', $consolidated, $history); |
|
129 | + $this->renderPage($this->templateDir.'/html_report/packages.php', $logDir.'/packages.html', $consolidated, $history); |
|
130 | + $this->renderPage($this->templateDir.'/html_report/package_relations.php', $logDir.'/package_relations.html', $consolidated, $history); |
|
131 | + $this->renderPage($this->templateDir.'/html_report/composer.php', $logDir.'/composer.html', $consolidated, $history); |
|
132 | 132 | if ($this->config->has('git')) { |
133 | - $this->renderPage($this->templateDir . '/html_report/git.php', $logDir . '/git.html', $consolidated, $consolidatedGroups, $history); |
|
133 | + $this->renderPage($this->templateDir.'/html_report/git.php', $logDir.'/git.html', $consolidated, $consolidatedGroups, $history); |
|
134 | 134 | } |
135 | - $this->renderPage($this->templateDir . '/html_report/junit.php', $logDir . '/junit.html', $consolidated, $consolidatedGroups, $history); |
|
135 | + $this->renderPage($this->templateDir.'/html_report/junit.php', $logDir.'/junit.html', $consolidated, $consolidatedGroups, $history); |
|
136 | 136 | |
137 | 137 | // js data |
138 | 138 | file_put_contents( |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | |
147 | 147 | // json data |
148 | 148 | file_put_contents( |
149 | - $logDir . '/classes.js', |
|
150 | - 'var classes = ' . json_encode($consolidated->getClasses(), JSON_PRETTY_PRINT) |
|
149 | + $logDir.'/classes.js', |
|
150 | + 'var classes = '.json_encode($consolidated->getClasses(), JSON_PRETTY_PRINT) |
|
151 | 151 | ); |
152 | 152 | |
153 | 153 | // HTML files to generate |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | // consolidated by groups |
170 | 170 | foreach ($consolidatedGroups as $name => $consolidated) { |
171 | - $outDir = $logDir . DIRECTORY_SEPARATOR . $name; |
|
171 | + $outDir = $logDir.DIRECTORY_SEPARATOR.$name; |
|
172 | 172 | $this->currentGroup = $name; |
173 | 173 | $this->assetPath = '../'; |
174 | 174 | |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | ); |
186 | 186 | |
187 | 187 | file_put_contents( |
188 | - $outDir . '/classes.js', |
|
189 | - 'var classes = ' . json_encode($consolidated->getClasses(), JSON_PRETTY_PRINT) |
|
188 | + $outDir.'/classes.js', |
|
189 | + 'var classes = '.json_encode($consolidated->getClasses(), JSON_PRETTY_PRINT) |
|
190 | 190 | ); |
191 | 191 | } |
192 | 192 | } |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | |
264 | 264 | $diff = $newValue - $oldValue; |
265 | 265 | if ($diff > 0) { |
266 | - $diff = '+' . $diff; |
|
266 | + $diff = '+'.$diff; |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | $goodOrBad = 'neutral'; |
@@ -51,8 +51,8 @@ |
||
51 | 51 | $name = getNameOfNode($node); |
52 | 52 | $classOrFunction = $this->metrics->get($name); |
53 | 53 | |
54 | - if(null === $classOrFunction) { |
|
55 | - throw new \LogicException('class or function ' . $name . ' not found in metrics'); |
|
54 | + if (null === $classOrFunction) { |
|
55 | + throw new \LogicException('class or function '.$name.' not found in metrics'); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | if (null === $lloc = $classOrFunction->get('lloc')) { |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | if (NodeTyper::isOrganizedLogicalClassStructure($node)) { |
43 | 43 | $class = $this->metrics->get(getNameOfNode($node)); |
44 | 44 | if (null === $class) { |
45 | - throw new \RuntimeException('Class metric not found for ' . getNameOfNode($node)); |
|
45 | + throw new \RuntimeException('Class metric not found for '.getNameOfNode($node)); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | $sy = $dc = $sc = []; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $fanout = []; |
55 | 55 | |
56 | 56 | $parentNode = $node; |
57 | - iterate_over_node($node, function ($node) use (&$output, &$fanout, $parentNode) { |
|
57 | + iterate_over_node($node, function($node) use (&$output, &$fanout, $parentNode) { |
|
58 | 58 | switch (true) { |
59 | 59 | case $node instanceof Stmt\Return_: |
60 | 60 | $output++; |
@@ -64,14 +64,14 @@ discard block |
||
64 | 64 | if ('static' === $class || 'self' === $class) { |
65 | 65 | $class = getNameOfNode($parentNode); |
66 | 66 | } |
67 | - $fanout[] = $class . '::' . getNameOfNode($node->name) . '()'; |
|
67 | + $fanout[] = $class.'::'.getNameOfNode($node->name).'()'; |
|
68 | 68 | break; |
69 | 69 | case $node instanceof Node\Expr\MethodCall: |
70 | 70 | $class = getNameOfNode($node->var); |
71 | 71 | if ('this' === $class) { |
72 | 72 | $class = getNameOfNode($parentNode); |
73 | 73 | } |
74 | - $fanout[] = $class . '->' . getNameOfNode($node->name) . '()'; |
|
74 | + $fanout[] = $class.'->'.getNameOfNode($node->name).'()'; |
|
75 | 75 | break; |
76 | 76 | } |
77 | 77 | }); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | NodeTyper::isOrganizedLogicalClassStructure($node) |
47 | 47 | || $node instanceof Stmt\Function_ |
48 | 48 | ) { |
49 | - if (NodeTyper::isOrganizedLogicalClassStructure($node) ) { |
|
49 | + if (NodeTyper::isOrganizedLogicalClassStructure($node)) { |
|
50 | 50 | $name = getNameOfNode($node); |
51 | 51 | $classOrFunction = $this->metrics->get($name); |
52 | 52 | } else { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $operands = []; |
59 | 59 | $operators = []; |
60 | 60 | |
61 | - iterate_over_node($node, function ($node) use (&$operators, &$operands) { |
|
61 | + iterate_over_node($node, function($node) use (&$operators, &$operands) { |
|
62 | 62 | if ($node instanceof Node\Expr\BinaryOp |
63 | 63 | || $node instanceof Node\Expr\AssignOp |
64 | 64 | || $node instanceof Stmt\If_ |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | if (NodeTyper::isOrganizedStructure($node)) { |
57 | 57 | $class = $this->metrics->get(getNameOfNode($node)); |
58 | 58 | if ($class === null) { |
59 | - throw new \RuntimeException('Class metric not found for ' . getNameOfNode($node)); |
|
59 | + throw new \RuntimeException('Class metric not found for '.getNameOfNode($node)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $ccn = 1; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | // iterate over children, recursively |
78 | - $cb = function ($node) use (&$cb) { |
|
78 | + $cb = function($node) use (&$cb) { |
|
79 | 79 | $ccn = 0; |
80 | 80 | |
81 | 81 | foreach (get_object_vars($node) as $name => $member) { |
@@ -66,7 +66,7 @@ |
||
66 | 66 | $roleDetector = new RoleOfMethodDetector(); |
67 | 67 | foreach ($node->stmts as $stmt) { |
68 | 68 | if ($stmt instanceof Stmt\ClassMethod) { |
69 | - $function = new FunctionMetric((string)$stmt->name); |
|
69 | + $function = new FunctionMetric((string) $stmt->name); |
|
70 | 70 | |
71 | 71 | $role = $roleDetector->detects($stmt); |
72 | 72 | $function->set('role', $role); |