Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#715)
by Alexander
03:10
created

AbstractController::loadDocument()   B

Complexity

Conditions 7
Paths 7

Size

Total Lines 46
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 30
c 0
b 0
f 0
dl 0
loc 46
rs 8.5066
cc 7
nc 7
nop 1
1
<?php
2
/**
3
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
4
 *
5
 * This file is part of the Kitodo and TYPO3 projects.
6
 *
7
 * @license GNU General Public License version 3 or later.
8
 * For the full copyright and license information, please read the
9
 * LICENSE.txt file that was distributed with this source code.
10
 */
11
12
namespace Kitodo\Dlf\Controller;
13
14
use Kitodo\Dlf\Common\Document;
15
use Kitodo\Dlf\Common\Helper;
16
use Psr\Log\LoggerAwareInterface;
17
use Psr\Log\LoggerAwareTrait;
18
use TYPO3\CMS\Core\Database\ConnectionPool;
19
use TYPO3\CMS\Core\Utility\GeneralUtility;
20
21
22
/**
23
 *
24
 */
25
abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController implements LoggerAwareInterface
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Extbase\Mvc\Controller\ActionController was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
{
27
    use LoggerAwareTrait;
28
29
    /**
30
     * Loads the current document into $this->doc
31
     *
32
     * @access protected
33
     *
34
     * @return void
35
     */
36
    protected function loadDocument($requestData)
37
    {
38
        // Check for required variable.
39
        if (
40
            !empty($requestData['id'])
41
            && !empty($this->settings['pages'])
42
        ) {
43
            // Should we exclude documents from other pages than $this->settings['pages']?
44
            $pid = (!empty($this->settings['excludeOther']) ? intval($this->settings['pages']) : 0);
45
            // Get instance of \Kitodo\Dlf\Common\Document.
46
            $this->doc = Document::getInstance($requestData['id'], $pid);
0 ignored issues
show
Bug Best Practice introduced by
The property doc does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
47
            if (!$this->doc->ready) {
48
                // Destroy the incomplete object.
49
                $this->doc = null;
50
                $this->logger->error('Failed to load document with UID ' . $requestData['id']);
1 ignored issue
show
Bug introduced by
The method error() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

50
                $this->logger->/** @scrutinizer ignore-call */ 
51
                               error('Failed to load document with UID ' . $requestData['id']);

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.

Loading history...
51
            } else {
52
                // Set configuration PID.
53
                $this->doc->cPid = $this->settings['pages'];
54
            }
55
        } elseif (!empty($requestData['recordId'])) {
56
            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
57
                ->getQueryBuilderForTable('tx_dlf_documents');
58
59
            // Get UID of document with given record identifier.
60
            $result = $queryBuilder
61
                ->select('tx_dlf_documents.uid AS uid')
62
                ->from('tx_dlf_documents')
63
                ->where(
64
                    $queryBuilder->expr()->eq('tx_dlf_documents.record_id', $queryBuilder->expr()->literal($requestData['recordId'])),
65
                    Helper::whereExpression('tx_dlf_documents')
66
                )
67
                ->setMaxResults(1)
68
                ->execute();
69
70
            if ($resArray = $result->fetch()) {
71
                $requestData['id'] = $resArray['uid'];
72
                // Set superglobal $_GET array and unset variables to avoid infinite looping.
73
                $_GET[$this->prefixId]['id'] = $requestData['id'];
74
                unset($requestData['recordId'], $_GET[$this->prefixId]['recordId']);
75
                // Try to load document.
76
                $this->loadDocument();
0 ignored issues
show
Bug introduced by
The call to Kitodo\Dlf\Controller\Ab...troller::loadDocument() has too few arguments starting with requestData. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

76
                $this->/** @scrutinizer ignore-call */ 
77
                       loadDocument();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
77
            } else {
78
                $this->logger->error('Failed to load document with record ID "' . $requestData['recordId'] . '"');
79
            }
80
        } else {
81
            $this->logger->error('Invalid UID ' . $requestData['id'] . ' or PID ' . $this->settings['pages'] . ' for document loading');
82
        }
83
    }
84
85
}
86