| Conditions | 5 |
| Paths | 7 |
| Total Lines | 53 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 45 | public function generate(Metrics $metrics) |
||
| 46 | { |
||
| 47 | $logDir = $this->config->get('report-html'); |
||
|
|
|||
| 48 | if (!$logDir) { |
||
| 49 | return; |
||
| 50 | } |
||
| 51 | |||
| 52 | $consolidated = new Consolidated($metrics); |
||
| 53 | |||
| 54 | $files = glob($logDir . '/js/history-*.json'); |
||
| 55 | natsort($files); |
||
| 56 | $history = array_map(static function ($filename) { |
||
| 57 | return json_decode(file_get_contents($filename)); |
||
| 58 | }, $files); |
||
| 59 | |||
| 60 | foreach (['js', 'css', 'images', 'fonts'] as $subFolder) { |
||
| 61 | $folder = $logDir . '/' . $subFolder; |
||
| 62 | if (!file_exists($folder)) { |
||
| 63 | mkdir($folder, 0755, true); |
||
| 64 | } |
||
| 65 | recurse_copy(__DIR__ . '/template/' . $subFolder, $folder); |
||
| 66 | } |
||
| 67 | |||
| 68 | // render dynamic pages |
||
| 69 | $this->renderPage(__DIR__ . '/template/index.php', $logDir . '/index.html', $consolidated, $history); |
||
| 70 | $this->renderPage(__DIR__ . '/template/loc.php', $logDir . '/loc.html', $consolidated, $history); |
||
| 71 | $this->renderPage(__DIR__ . '/template/relations.php', $logDir . '/relations.html', $consolidated, $history); |
||
| 72 | $this->renderPage(__DIR__ . '/template/coupling.php', $logDir . '/coupling.html', $consolidated, $history); |
||
| 73 | $this->renderPage(__DIR__ . '/template/all.php', $logDir . '/all.html', $consolidated, $history); |
||
| 74 | $this->renderPage(__DIR__ . '/template/oop.php', $logDir . '/oop.html', $consolidated, $history); |
||
| 75 | $this->renderPage(__DIR__ . '/template/complexity.php', $logDir . '/complexity.html', $consolidated, $history); |
||
| 76 | $this->renderPage(__DIR__ . '/template/panel.php', $logDir . '/panel.html', $consolidated, $history); |
||
| 77 | $this->renderPage(__DIR__ . '/template/violations.php', $logDir . '/violations.html', $consolidated, $history); |
||
| 78 | $this->renderPage(__DIR__ . '/template/packages.php', $logDir . '/packages.html', $consolidated, $history); |
||
| 79 | $this->renderPage(__DIR__ . '/template/package_relations.php', $logDir . '/package_relations.html', $consolidated, $history); |
||
| 80 | if ($this->config->has('git')) { |
||
| 81 | $this->renderPage(__DIR__ . '/template/git.php', $logDir . '/git.html', $consolidated, $history); |
||
| 82 | } |
||
| 83 | $this->renderPage(__DIR__ . '/template/junit.php', $logDir . '/junit.html', $consolidated, $history); |
||
| 84 | |||
| 85 | $today = (object)['avg' => $consolidated->getAvg(), 'sum' => $consolidated->getSum()]; |
||
| 86 | $encodedToday = json_encode($today, JSON_PRETTY_PRINT); |
||
| 87 | $next = count($history) + 1; |
||
| 88 | file_put_contents(sprintf('%s/js/history-%d.json', $logDir, $next), $encodedToday); |
||
| 89 | file_put_contents(sprintf('%s/js/latest.json', $logDir), $encodedToday); |
||
| 90 | |||
| 91 | file_put_contents( |
||
| 92 | $logDir . '/js/classes.js', |
||
| 93 | 'var classes = ' . json_encode($consolidated->getClasses(), JSON_PRETTY_PRINT) |
||
| 94 | ); |
||
| 95 | |||
| 96 | $this->output->writeln(sprintf('HTML report generated in "%s" directory', $logDir)); |
||
| 97 | } |
||
| 98 | |||
| 180 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.