| Conditions | 7 |
| Paths | 7 |
| Total Lines | 51 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 38 | public function run($request) |
||
| 39 | { |
||
| 40 | $this->request = $request; |
||
| 41 | |||
| 42 | set_time_limit(0); |
||
| 43 | SubsiteHelper::disableFilter(); |
||
| 44 | $admin = self::getAssetAdmin(); |
||
| 45 | |||
| 46 | $originalDir = BASE_PATH . '/' . Director::publicDir() . '/assets/'; |
||
| 47 | |||
| 48 | $files = File::get(); |
||
| 49 | |||
| 50 | $this->message("Processing {$files->count()} files"); |
||
| 51 | |||
| 52 | $i = 0; |
||
| 53 | foreach ($files as $file) { |
||
| 54 | $i++; |
||
| 55 | $name = $file->getFilename(); |
||
| 56 | |||
| 57 | if (!$name) { |
||
| 58 | continue; |
||
| 59 | } |
||
| 60 | |||
| 61 | $originalName = $originalDir . $name; |
||
| 62 | |||
| 63 | // Generate a file hash if not set |
||
| 64 | if (!$file->getField('FileHash') && is_file($originalName)) { |
||
| 65 | $hash = sha1_file($originalName); |
||
| 66 | DB::query('UPDATE "File" SET "FileHash" = \'' . $hash . '\' WHERE "ID" = \'' . $file->ID . '\' LIMIT 1;'); |
||
| 67 | $targetDir = str_replace('./', '', BASE_PATH . '/' . Director::publicDir() . '/assets/.protected/' . dirname($name) |
||
| 68 | . '/' . substr($hash, 0, 10) . '/'); |
||
| 69 | if (!file_exists($targetDir)) { |
||
| 70 | mkdir($targetDir, 0755, true); |
||
| 71 | } |
||
| 72 | rename($originalDir . $name, $targetDir . basename($name)); |
||
| 73 | echo '<b style="color:red">' . $originalDir . $name . ' > ' . $targetDir . basename($name) . '</b><br>'; |
||
| 74 | } else { |
||
| 75 | // Will only apply to images |
||
| 76 | $admin->generateThumbnails($file); |
||
| 77 | // Publish |
||
| 78 | try { |
||
| 79 | $file->copyVersionToStage('Stage', 'Live'); |
||
| 80 | $this->message("Published $name", "created"); |
||
| 81 | } catch (Exception $ex) { |
||
| 82 | $this->message($ex->getMessage(), "error"); |
||
| 83 | } |
||
| 84 | } |
||
| 85 | |||
| 86 | $file->destroy(); |
||
| 87 | } |
||
| 88 | $this->message("Processed $i files"); |
||
| 89 | } |
||
| 96 |
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