| Conditions | 14 |
| Paths | 32 |
| Total Lines | 63 |
| Code Lines | 38 |
| 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 |
||
| 77 | private static function parseSeparator(Cursor $cursor): array |
||
| 78 | { |
||
| 79 | $columns = []; |
||
| 80 | $pipes = 0; |
||
| 81 | $valid = false; |
||
| 82 | |||
| 83 | while (! $cursor->isAtEnd()) { |
||
| 84 | switch ($c = $cursor->getCurrentCharacter()) { |
||
| 85 | case '|': |
||
| 86 | $cursor->advanceBy(1); |
||
| 87 | $pipes++; |
||
| 88 | if ($pipes > 1) { |
||
| 89 | // More than one adjacent pipe not allowed |
||
| 90 | return []; |
||
| 91 | } |
||
| 92 | |||
| 93 | // Need at least one pipe, even for a one-column table |
||
| 94 | $valid = true; |
||
| 95 | break; |
||
| 96 | case '-': |
||
| 97 | case ':': |
||
| 98 | if ($pipes === 0 && \count($columns) > 0) { |
||
| 99 | // Need a pipe after the first column (first column doesn't need to start with one) |
||
| 100 | return []; |
||
| 101 | } |
||
| 102 | |||
| 103 | $left = false; |
||
| 104 | $right = false; |
||
| 105 | if ($c === ':') { |
||
| 106 | $left = true; |
||
| 107 | $cursor->advanceBy(1); |
||
| 108 | } |
||
| 109 | |||
| 110 | if ($cursor->match('/^-+/') === null) { |
||
| 111 | // Need at least one dash |
||
| 112 | return []; |
||
| 113 | } |
||
| 114 | |||
| 115 | if ($cursor->getCurrentCharacter() === ':') { |
||
| 116 | $right = true; |
||
| 117 | $cursor->advanceBy(1); |
||
| 118 | } |
||
| 119 | |||
| 120 | $columns[] = self::getAlignment($left, $right); |
||
| 121 | // Next, need another pipe |
||
| 122 | $pipes = 0; |
||
| 123 | break; |
||
| 124 | case ' ': |
||
| 125 | case "\t": |
||
| 126 | // White space is allowed between pipes and columns |
||
| 127 | $cursor->advanceToNextNonSpaceOrTab(); |
||
| 128 | break; |
||
| 129 | default: |
||
| 130 | // Any other character is invalid |
||
| 131 | return []; |
||
| 132 | } |
||
| 133 | } |
||
| 134 | |||
| 135 | if (! $valid) { |
||
| 136 | return []; |
||
| 137 | } |
||
| 138 | |||
| 139 | return $columns; |
||
| 140 | } |
||
| 166 |
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