| Conditions | 4 |
| Paths | 18 |
| Total Lines | 55 |
| 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 |
||
| 35 | public function handle(): int |
||
| 36 | { |
||
| 37 | $groupId = $this->argument('groupId'); |
||
| 38 | |||
| 39 | if (! is_numeric($groupId)) { |
||
| 40 | $this->error('Group ID must be numeric.'); |
||
| 41 | |||
| 42 | return self::FAILURE; |
||
| 43 | } |
||
| 44 | |||
| 45 | try { |
||
| 46 | $groupMySQL = UsenetGroup::find($groupId)->toArray(); |
||
| 47 | |||
| 48 | if ($groupMySQL === null) { |
||
| 49 | $this->error("Group not found with id {$groupId}"); |
||
| 50 | |||
| 51 | return self::FAILURE; |
||
| 52 | } |
||
| 53 | |||
| 54 | $nntp = $this->getNntp(); |
||
| 55 | $backFill = new Backfill; |
||
| 56 | |||
| 57 | // Update the group for new binaries |
||
| 58 | $this->info("Updating binaries for group: {$groupMySQL['name']}"); |
||
| 59 | (new Binaries)->updateGroup($groupMySQL); |
||
| 60 | |||
| 61 | // BackFill the group with 20k articles |
||
| 62 | $this->info("Backfilling group: {$groupMySQL['name']}"); |
||
| 63 | $backFill->backfillAllGroups($groupMySQL['name'], 20000, 'normal'); |
||
| 64 | |||
| 65 | // Create releases |
||
| 66 | $this->info("Processing releases for group: {$groupMySQL['name']}"); |
||
| 67 | $this->processReleases(new ProcessReleases, $groupId); |
||
| 68 | |||
| 69 | // Post process the releases |
||
| 70 | $this->info("Post-processing additional for group: {$groupMySQL['name']}"); |
||
| 71 | (new ProcessAdditional(['Echo' => true, 'NNTP' => $nntp]))->start($groupId); |
||
|
|
|||
| 72 | |||
| 73 | $this->info("Processing NFO files for group: {$groupMySQL['name']}"); |
||
| 74 | (new Nfo)->processNfoFiles( |
||
| 75 | $nntp, |
||
| 76 | $groupId, |
||
| 77 | '', |
||
| 78 | (int) Settings::settingValue('lookupimdb'), |
||
| 79 | (int) Settings::settingValue('lookuptv') |
||
| 80 | ); |
||
| 81 | |||
| 82 | $this->info("Completed all processing for group: {$groupMySQL['name']}"); |
||
| 83 | |||
| 84 | return self::SUCCESS; |
||
| 85 | } catch (\Throwable $e) { |
||
| 86 | Log::error($e->getTraceAsString()); |
||
| 87 | $this->error($e->getMessage()); |
||
| 88 | |||
| 89 | return self::FAILURE; |
||
| 90 | } |
||
| 131 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.