| Conditions | 6 |
| Paths | 16 |
| Total Lines | 61 |
| Code Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 11 | ||
| Bugs | 4 | 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 |
||
| 60 | public function run(){ |
||
| 61 | if (!$this->initFS()) { |
||
|
|
|||
| 62 | return; |
||
| 63 | } |
||
| 64 | // locate files that are not checked yet |
||
| 65 | $dirMimeTypeId = \OC::$server->getMimeTypeLoader()->getId('httpd/unix-directory'); |
||
| 66 | try { |
||
| 67 | $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder(); |
||
| 68 | $qb->select(['fc.fileid']) |
||
| 69 | ->from('filecache', 'fc') |
||
| 70 | ->leftJoin('fc', 'files_antivirus', 'fa', $qb->expr()->eq('fa.fileid', 'fc.fileid')) |
||
| 71 | ->innerJoin( |
||
| 72 | 'fc', |
||
| 73 | 'storages', |
||
| 74 | 'ss', |
||
| 75 | $qb->expr()->andX( |
||
| 76 | $qb->expr()->eq('fc.storage', 'ss.numeric_id'), |
||
| 77 | $qb->expr()->orX( |
||
| 78 | $qb->expr()->like('ss.id', $qb->expr()->literal('local::%')), |
||
| 79 | $qb->expr()->like('ss.id', $qb->expr()->literal('home::%')) |
||
| 80 | ) |
||
| 81 | ) |
||
| 82 | ) |
||
| 83 | ->where( |
||
| 84 | $qb->expr()->neq('fc.mimetype', $qb->expr()->literal($dirMimeTypeId)) |
||
| 85 | ) |
||
| 86 | ->andWhere( |
||
| 87 | $qb->expr()->orX( |
||
| 88 | $qb->expr()->isNull('fa.fileid'), |
||
| 89 | $qb->expr()->gt('fc.mtime', 'fa.check_time') |
||
| 90 | ) |
||
| 91 | ) |
||
| 92 | ->andWhere( |
||
| 93 | $qb->expr()->like('fc.path', $qb->expr()->literal('files/%')) |
||
| 94 | ) |
||
| 95 | ->andWhere( |
||
| 96 | $qb->expr()->neq('fc.size', '?1') |
||
| 97 | ) |
||
| 98 | ->setMaxResults(self::BATCH_SIZE) |
||
| 99 | ; |
||
| 100 | $result = $qb->execute([0]); |
||
| 101 | } catch(\Exception $e) { |
||
| 102 | \OC::$server->getLogger()->error( __METHOD__ . ', exception: ' . $e->getMessage(), ['app' => 'files_antivirus']); |
||
| 103 | return; |
||
| 104 | } |
||
| 105 | |||
| 106 | try { |
||
| 107 | while ($row = $result->fetch()) { |
||
| 108 | $path = $view->getPath($row['fileid']); |
||
| 109 | if (!is_null($path)) { |
||
| 110 | $item = new Item($this->l10n, $view, $path, $row['fileid']); |
||
| 111 | $scanner = $this->scannerFactory->getScanner(); |
||
| 112 | $status = $scanner->scan($item); |
||
| 113 | $status->dispatch($item, true); |
||
| 114 | } |
||
| 115 | } |
||
| 116 | } catch (\Exception $e){ |
||
| 117 | \OC::$server->getLogger()->error( __METHOD__ . ', exception: ' . $e->getMessage(), ['app' => 'files_antivirus']); |
||
| 118 | } |
||
| 119 | \OC_Util::tearDownFS(); |
||
| 120 | } |
||
| 121 | |||
| 174 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.