Conditions | 19 |
Paths | 624 |
Total Lines | 78 |
Code Lines | 57 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
134 | public function updateTableRepositories($user, $repos = [], $updateAddtionals = true, $dirContent = 0) |
||
135 | { |
||
136 | $reposNb = 0; |
||
137 | $helper = \XoopsModules\Wggithub\Helper::getInstance(); |
||
138 | $repositoriesHandler = $helper->getHandler('Repositories'); |
||
139 | |||
140 | $submitter = isset($GLOBALS['xoopsUser']) && \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; |
||
141 | // add/update all items from table repositories |
||
142 | foreach ($repos as $key => $repo) { |
||
143 | $fork = (bool)$repo['fork']; |
||
144 | if (Constants::DIRECTORY_CONTENT_ALL == $dirContent || false === $fork) { |
||
145 | $crRepositories = new \CriteriaCompo(); |
||
146 | $crRepositories->add(new \Criteria('repo_nodeid', $repo['node_id'])); |
||
147 | $repoId = 0; |
||
148 | $status = 0; |
||
149 | $updatedAtOld = 0; |
||
150 | $updatedAtNew = 0; |
||
151 | $repositoriesAll = $repositoriesHandler->getAll($crRepositories); |
||
152 | foreach (\array_keys($repositoriesAll) as $i) { |
||
153 | $repoId = $repositoriesAll[$i]->getVar('repo_id'); |
||
154 | $updatedAtOld = $repositoriesAll[$i]->getVar('repo_updatedat'); |
||
155 | $status = $repositoriesAll[$i]->getVar('repo_status'); |
||
156 | $repositoriesObj = $repositoriesAll[$i]; |
||
157 | } |
||
158 | if ($repoId > 0) { |
||
159 | if (\is_string($repo['pushed_at'])) { |
||
160 | $updatedAtNew = \strtotime($repo['pushed_at']); |
||
161 | } elseif (\is_string($repo['updated_at'])) { |
||
162 | $updatedAtNew = \strtotime($repo['updated_at']); |
||
163 | } |
||
164 | if ($updatedAtOld != Constants::STATUS_OFFLINE && $updatedAtOld != $updatedAtNew) { |
||
165 | $status = Constants::STATUS_UPDATED; |
||
166 | } |
||
167 | } else { |
||
168 | $repositoriesObj = $repositoriesHandler->create(); |
||
169 | $updatedAtNew = \strtotime($repo['updated_at']); |
||
170 | $status = Constants::STATUS_NEW; |
||
171 | } |
||
172 | if (Constants::STATUS_UPTODATE !== $status) { |
||
173 | // Set Vars |
||
174 | $repositoriesObj->setVar('repo_nodeid', $repo['node_id']); |
||
175 | $repositoriesObj->setVar('repo_user', $user); |
||
176 | $repositoriesObj->setVar('repo_name', $repo['name']); |
||
177 | $repositoriesObj->setVar('repo_fullname', $repo['full_name']); |
||
178 | if (\is_string($repo['created_at'])) { |
||
179 | $createdAt = \strtotime($repo['created_at']); |
||
180 | } |
||
181 | $repositoriesObj->setVar('repo_createdat', $createdAt); |
||
182 | $repositoriesObj->setVar('repo_updatedat', $updatedAtNew); |
||
183 | $repositoriesObj->setVar('repo_htmlurl', $repo['html_url']); |
||
184 | $repositoriesObj->setVar('repo_status', $status); |
||
185 | $repositoriesObj->setVar('repo_datecreated', \time()); |
||
186 | $repositoriesObj->setVar('repo_submitter', $submitter); |
||
187 | // Insert Data |
||
188 | if ($repositoriesHandler->insert($repositoriesObj)) { |
||
189 | $newRepoId = $repositoriesObj->getNewInsertedIdRepositories(); |
||
190 | if (0 == $repoId) { |
||
191 | $repoId = $newRepoId; |
||
192 | } |
||
193 | $reposNb++; |
||
194 | if ($updateAddtionals && (Constants::STATUS_NEW == $status || Constants::STATUS_UPDATED == $status)) { |
||
195 | // add/update table readmes |
||
196 | $helper->getHandler('Readmes')->updateReadmes($repoId, $user, $repo['name']); |
||
197 | // add/update table release |
||
198 | $helper->getHandler('Releases')->updateReleases($repoId, $user, $repo['name']); |
||
199 | // change status to updated |
||
200 | $repositoriesObj = $repositoriesHandler->get($repoId); |
||
201 | $repositoriesObj->setVar('repo_status', Constants::STATUS_UPTODATE); |
||
202 | $repositoriesHandler->insert($repositoriesObj, true); |
||
203 | } |
||
204 | } else { |
||
205 | return false; |
||
206 | } |
||
207 | } |
||
208 | } |
||
209 | } |
||
210 | |||
211 | return $reposNb; |
||
212 | } |
||
265 |
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