| Conditions | 8 | 
| Paths | 24 | 
| Total Lines | 69 | 
| Code Lines | 41 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 4 | ||
| Bugs | 1 | 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 declare(strict_types = 1);  | 
            ||
| 39 | public function run($request)  | 
            ||
| 40 |     { | 
            ||
| 41 | $climate = new CLImate();  | 
            ||
| 42 | |||
| 43 | // check this script is being run by admin  | 
            ||
| 44 |         $canAccess = (Director::isDev() || Director::is_cli() || Permission::check("ADMIN")); | 
            ||
| 45 |         if (!$canAccess) { | 
            ||
| 46 | return Security::permissionFailure($this);  | 
            ||
| 47 | }  | 
            ||
| 48 | |||
| 49 | /** @var string $indexName */  | 
            ||
| 50 |         $indexName = $request->getVar('index'); | 
            ||
| 51 | $indexes = new Indexes();  | 
            ||
| 52 | $index = $indexes->getIndex($indexName);  | 
            ||
| 53 | |||
| 54 | /** @var string $clazz */  | 
            ||
| 55 | $clazz = $index->getClass();  | 
            ||
| 56 | |||
| 57 | |||
| 58 | $startTime = microtime(true);  | 
            ||
| 59 | |||
| 60 | $climate->border();  | 
            ||
| 61 |         $climate->green()->bold('Indexing sitetree'); | 
            ||
| 62 | $climate->border();  | 
            ||
| 63 | |||
| 64 | $nDocuments = SiteTree::get()->count();  | 
            ||
| 65 | $bulkSize = 500; // @todo configurable  | 
            ||
| 66 | $pages = 1+round($nDocuments / $bulkSize);  | 
            ||
| 67 |         $climate->green('Pages: ' . $pages); | 
            ||
| 68 |         $climate->green()->info('Indexing ' . $nDocuments .' objects'); | 
            ||
| 69 | $progress = $climate->progress()->total($nDocuments);  | 
            ||
| 70 | |||
| 71 | $factory = new BulkIndexerFactory();  | 
            ||
| 72 | $bulkIndexer = $factory->getBulkIndexer();  | 
            ||
| 73 | $bulkIndexer->setIndex($indexName);  | 
            ||
| 74 | |||
| 75 | for ($i = 0; $i < $pages; $i++)  | 
            ||
| 76 |         { | 
            ||
| 77 |             $dataObjects = $clazz::get()->limit($bulkSize, $i*$bulkSize)->filter('ShowInSearch', true); | 
            ||
| 78 |             foreach($dataObjects as $do) { | 
            ||
| 79 | // @hack @todo FIX  | 
            ||
| 80 |                 if ($do->ID !== 6) { | 
            ||
| 81 | $bulkIndexer->addDataObject($do);  | 
            ||
| 82 | }  | 
            ||
| 83 | |||
| 84 | }  | 
            ||
| 85 | $bulkIndexer->indexDataObjects();  | 
            ||
| 86 | $current = $bulkSize * ($i+1);  | 
            ||
| 87 |             if ($current > $nDocuments) { | 
            ||
| 88 | $current = $nDocuments;  | 
            ||
| 89 | }  | 
            ||
| 90 | $progress->current($current);  | 
            ||
| 91 | }  | 
            ||
| 92 | |||
| 93 | |||
| 94 | |||
| 95 | $endTime = microtime(true);  | 
            ||
| 96 | $delta = $endTime-$startTime;  | 
            ||
| 97 | |||
| 98 | $rate = round($nDocuments / $delta, 2);  | 
            ||
| 99 | |||
| 100 | $elapsedStr = round($delta, 2);  | 
            ||
| 101 | |||
| 102 |         $climate->bold()->blue()->inline("{$nDocuments}"); | 
            ||
| 103 |         $climate->blue()->inline(' objects indexed in '); | 
            ||
| 104 |         $climate->bold()->blue()->inline("{$elapsedStr}"); | 
            ||
| 105 |         $climate->blue()->inline('s, '); | 
            ||
| 106 |         $climate->bold()->blue()->inline("{$rate}"); | 
            ||
| 107 |         $climate->blue(' per second '); | 
            ||
| 108 | |||
| 111 | 
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