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