owncloud/core

View on GitHub

Showing 3,236 of 4,502 total issues

Function send has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function send($type, $data = null) {
        if ($data and !\preg_match('/^[A-Za-z0-9_]+$/', $type)) {
            throw new BadMethodCallException('Type needs to be alphanumeric ('. $type .')');
        }
        $this->init();
Severity: Minor
Found in lib/private/legacy/eventsource.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function isValidFileName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function isValidFileName($file) {
        $trimmed = \trim($file);
        if ($trimmed === '') {
            return false;
        }
Severity: Minor
Found in lib/private/legacy/util.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function changeLock has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function changeLock($path, $targetType) {
        $expire = $this->getExpireTime();
        if ($targetType === self::LOCK_SHARED) {
            $result = $this->connection->executeUpdate(
                'UPDATE `*PREFIX*file_locks` SET `lock` = 1, `ttl` = ? WHERE `key` = ? AND `lock` = -1',
Severity: Minor
Found in lib/private/Lock/DBLockingProvider.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function saveSchemaToFile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function saveSchemaToFile($file, \OC\DB\Connection $conn) {
        $config = \OC::$server->getConfig();

        $xml = new \SimpleXMLElement('<database/>');
        $xml->addChild('name', $config->getSystemValue('dbname', 'owncloud'));
Severity: Minor
Found in lib/private/DB/MDB2SchemaWriter.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function getUserQuota has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getUserQuota($userId) {
        if ($userId instanceof IUser) {
            $user = $userId;
        } else {
            $user = \OC::$server->getUserManager()->get($userId);
Severity: Minor
Found in lib/private/legacy/util.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute($jobList, ILogger $logger = null) {
        if ((\time() - $this->lastRun) > $this->interval) {
            if ($logger !== null) {
                $id = $this->getId();
                $class = \get_class($this);
Severity: Minor
Found in lib/private/BackgroundJob/TimedJob.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function tryTokenLogin has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function tryTokenLogin(IRequest $request) {
        $authHeader = $request->getHeader('Authorization');
        if ($authHeader === null || \strpos($authHeader, 'token ') === false) {
            // No auth header, let's try session id
            try {
Severity: Minor
Found in lib/private/User/Session.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function markChange has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function markChange($path, $targetType) {
        if ($targetType === self::LOCK_SHARED) {
            unset($this->acquiredLocks['exclusive'][$path]);
            if (!isset($this->acquiredLocks['shared'][$path])) {
                $this->acquiredLocks['shared'][$path] = 0;
Severity: Minor
Found in lib/private/Lock/AbstractLockingProvider.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function getUser has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getUser() {
        // FIXME: This is a quick'n dirty work-around for the incognito mode as
        // described at https://github.com/owncloud/core/pull/12912#issuecomment-67391155
        if (OC_User::isIncognitoMode()) {
            return null;
Severity: Minor
Found in lib/private/User/Session.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function tryBasicAuthLogin has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function tryBasicAuthLogin(IRequest $request) {
        if (!empty($request->server['PHP_AUTH_USER']) && !empty($request->server['PHP_AUTH_PW'])) {
            try {
                if ($this->logClientIn($request->server['PHP_AUTH_USER'], $request->server['PHP_AUTH_PW'], $request)) {
                    /**
Severity: Minor
Found in lib/private/User/Session.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function checkTokenCredentials has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkTokenCredentials(IToken $dbToken, $token) {
        // Check whether login credentials are still valid and the user was not disabled
        // This check is performed each 5 minutes per default
        // However, we try to read last_check_timeout from the appconfig table so the
        // administrator could change this 5 minutes timeout
Severity: Minor
Found in lib/private/User/Session.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function add has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function add($job, $argument = null) {
        if (!$this->has($job, $argument)) {
            if ($job instanceof IJob) {
                $class = \get_class($job);
            } else {
Severity: Minor
Found in lib/private/BackgroundJob/JobList.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function getToken has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getToken(IRequest $request, &$token) {
        $authHeader = $request->getHeader('Authorization');
        if ($authHeader === null || \strpos($authHeader, 'token ') === false) {
            // No auth header, let's try session id
            try {
Severity: Minor
Found in lib/private/User/TokenAuthModule.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function getL10nFilesForApp has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getL10nFilesForApp($app, $lang) {
        $languageFiles = [];

        $i18nDir = $this->findL10nDir($app);
        $transFile = \strip_tags($i18nDir) . \strip_tags($lang) . '.json';
Severity: Minor
Found in lib/private/L10N/Factory.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function findL10nDirInTheme has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function findL10nDirInTheme(string $themeDir, $app): string {
        if ($app) {
            if (\in_array($app, ['core', 'lib', 'settings'])) {
                $p = $themeDir . '/' . $app . '/l10n/';
            } else {
Severity: Minor
Found in lib/private/L10N/Factory.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function prepareCommentForDatabaseWrite has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function prepareCommentForDatabaseWrite(IComment $comment) {
        if (!$comment->getActorType()
            || !$comment->getActorId()
            || !$comment->getObjectType()
            || !$comment->getObjectId()
Severity: Minor
Found in lib/private/Comments/Manager.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function syncUserName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function syncUserName(Account $a, UserInterface $backend) {
        $uid = $a->getUserId();
        if ($backend instanceof IProvidesUserNameBackend) {
            $userName = $backend->getUserName($uid);
            $currentUserName = $this->config->getUserValue($uid, 'core', 'username', null);
Severity: Minor
Found in lib/private/User/SyncService.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function checkPassword has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function checkPassword($uid, $password) {
        $query = \OC_DB::prepare('SELECT `uid`, `password` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)');
        $result = $query->execute([$uid]);

        $row = $result->fetchRow();
Severity: Minor
Found in lib/private/User/Database.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function fromArray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function fromArray($data) {
        foreach (\array_keys($data) as $key) {
            // translate DB keys to internal setter names
            $setter = 'set' . \implode('', \array_map('ucfirst', \explode('_', $key)));
            $setter = \str_replace('Timestamp', 'DateTime', $setter);
Severity: Minor
Found in lib/private/Comments/Comment.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function setUserValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function setUserValue($userId, $appName, $key, $value, $preCondition = null) {
        if (!\is_int($value) && !\is_float($value) && !\is_string($value)) {
            throw new \UnexpectedValueException('Only integers, floats and strings are allowed as value');
        }

Severity: Minor
Found in lib/private/AllConfig.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Severity
Category
Status
Source
Language