| Conditions | 13 |
| Paths | 80 |
| Total Lines | 111 |
| Code Lines | 56 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 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 |
||
| 34 | public function run($request) |
||
| 35 | { |
||
| 36 | Environment::increaseTimeLimitTo(); |
||
| 37 | Environment::increaseMemoryLimitTo(); |
||
| 38 | |||
| 39 | $tableHTML = ' |
||
| 40 | <table> |
||
| 41 | <thead> |
||
| 42 | <tr> |
||
| 43 | <th>Count</th> |
||
| 44 | <th>Links</th> |
||
| 45 | <th>Title</th> |
||
| 46 | <th>Content</th> |
||
| 47 | </tr> |
||
| 48 | </thead> |
||
| 49 | <tbody> |
||
| 50 | '; |
||
| 51 | $ids = []; |
||
| 52 | if ($request->getVar('ids')) { |
||
| 53 | $ids = explode(',', (string) $request->getVar('ids')); |
||
| 54 | } |
||
| 55 | if ($request->getVar('type')) { |
||
| 56 | $this->type = $request->getVar('type'); |
||
| 57 | } |
||
| 58 | $objects = DataList::create(); |
||
| 59 | if (count($ids)) { |
||
| 60 | echo $tableHTML; |
||
| 61 | $objects = SiteTree::get()->sort(['ID' => 'ASC'])->filter(['ID' => $ids]); |
||
| 62 | foreach ($objects as $object) { |
||
| 63 | $this->printFields($object); |
||
| 64 | } |
||
| 65 | } else { |
||
| 66 | echo ' |
||
| 67 | By default 200 random pages are loaded. |
||
| 68 | |||
| 69 | '; |
||
| 70 | |||
| 71 | echo $tableHTML; |
||
| 72 | |||
| 73 | if ($request->getVar('page')) { |
||
| 74 | if ('all' === $request->getVar('page')) { |
||
| 75 | $isPage = false; |
||
| 76 | $limit = 5000; |
||
| 77 | $this->step = 10; |
||
| 78 | $start = 0; |
||
| 79 | } else { |
||
| 80 | $isPage = true; |
||
| 81 | $limit = 500; |
||
| 82 | $start = $limit * ((int) $request->getVar('page') - 1); |
||
| 83 | echo '<h1>Page: ' . (int) $request->getVar('page') . '</h1>'; |
||
| 84 | } |
||
| 85 | } else { |
||
| 86 | $isPage = false; |
||
| 87 | $limit = 50; |
||
| 88 | $this->step = 51; |
||
| 89 | $start = 0; |
||
| 90 | echo '<h1>Random Selection</h1>'; |
||
| 91 | } |
||
| 92 | for ($i = 0; $i < $limit; $i += $this->step) { |
||
| 93 | $objects = null; |
||
| 94 | if ($isPage) { |
||
| 95 | $objects = SiteTree::get()->sort(['ID' => 'ASC'])->limit($this->step, $i + $start); |
||
| 96 | } |
||
| 97 | $filter = $this->Config()->get('filtered_class_names'); |
||
| 98 | if (! empty($filter)) { |
||
| 99 | $objects = $objects->filter($filter); |
||
| 100 | } |
||
| 101 | foreach ($objects as $object) { |
||
| 102 | $this->printFields($object); |
||
| 103 | } |
||
| 104 | } |
||
| 105 | } |
||
| 106 | $linksAll = []; |
||
| 107 | ksort($this->allLinks); |
||
| 108 | foreach ($this->allLinks as $url => $details) { |
||
| 109 | $linksAll[] = $url . ' | ' . $details['count']; |
||
| 110 | } |
||
| 111 | echo ' |
||
| 112 | <tr> |
||
| 113 | <th>---</th> |
||
| 114 | <th>---</th> |
||
| 115 | <th>Full List of Links</th> |
||
| 116 | <th> |
||
| 117 | <ul> |
||
| 118 | <li> |
||
| 119 | ' . implode('</li><li>', $linksAll) . ' |
||
| 120 | </li> |
||
| 121 | </ul> |
||
| 122 | </th> |
||
| 123 | </tr> |
||
| 124 | '; |
||
| 125 | $replacementsAll = []; |
||
| 126 | ksort($this->replacements); |
||
| 127 | foreach ($this->replacements as $details) { |
||
| 128 | $replacementsAll[] = 'FR: ' . $details['from'] . '<br />TO: ' . $details['to'] . '<br />RS: ' . $details['result'] . '<br /><br />'; |
||
| 129 | } |
||
| 130 | echo ' |
||
| 131 | <tr> |
||
| 132 | <th>---</th> |
||
| 133 | <th>---</th> |
||
| 134 | <th>Full List of Links</th> |
||
| 135 | <th> |
||
| 136 | <ul> |
||
| 137 | <li> |
||
| 138 | ' . implode('</li><li>', $replacementsAll) . ' |
||
| 139 | </li> |
||
| 140 | </ul> |
||
| 141 | </th> |
||
| 142 | </tr> |
||
| 143 | '; |
||
| 144 | echo '</tbody></table>'; |
||
| 145 | } |
||
| 265 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths