Conditions | 6 |
Paths | 14 |
Total Lines | 55 |
Code Lines | 34 |
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 declare(strict_types=1); |
||
72 | private function loadSnippetFilesInDir(string $snippetDir, Bundle $bundle): array |
||
73 | { |
||
74 | $finder = new Finder(); |
||
75 | $finder->in($snippetDir) |
||
76 | ->files() |
||
77 | ->name('*.json'); |
||
78 | |||
79 | try { |
||
80 | /** @var array<string, string> $authors */ |
||
81 | $authors = $this->connection->fetchAllKeyValue(' |
||
82 | SELECT `base_class` AS `baseClass`, `author` |
||
83 | FROM `plugin` |
||
84 | '); |
||
85 | } catch (Exception) { |
||
86 | // to get it working in setup without a database connection |
||
87 | $authors = []; |
||
88 | } |
||
89 | |||
90 | $snippetFiles = []; |
||
91 | |||
92 | foreach ($finder->getIterator() as $fileInfo) { |
||
93 | $nameParts = explode('.', $fileInfo->getFilenameWithoutExtension()); |
||
94 | |||
95 | $snippetFile = null; |
||
96 | switch (\count($nameParts)) { |
||
97 | case 2: |
||
98 | $snippetFile = new GenericSnippetFile( |
||
99 | implode('.', $nameParts), |
||
100 | $fileInfo->getPathname(), |
||
101 | $nameParts[1], |
||
102 | $this->getAuthorFromBundle($bundle, $authors), |
||
103 | false, |
||
104 | $bundle->getName() |
||
105 | ); |
||
106 | |||
107 | break; |
||
108 | case 3: |
||
109 | $snippetFile = new GenericSnippetFile( |
||
110 | implode('.', [$nameParts[0], $nameParts[1]]), |
||
111 | $fileInfo->getPathname(), |
||
112 | $nameParts[1], |
||
113 | $this->getAuthorFromBundle($bundle, $authors), |
||
114 | $nameParts[2] === 'base', |
||
115 | $bundle->getName() |
||
116 | ); |
||
117 | |||
118 | break; |
||
119 | } |
||
120 | |||
121 | if ($snippetFile) { |
||
122 | $snippetFiles[] = $snippetFile; |
||
123 | } |
||
124 | } |
||
125 | |||
126 | return $snippetFiles; |
||
127 | } |
||
141 |
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