owncloud/core

View on GitHub

Showing 4,482 of 4,482 total issues

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

    public static function humanFileSize($bytes) {
        if ($bytes < 0) {
            return "?";
        }
        if ($bytes < 1024) {
Severity: Minor
Found in lib/private/legacy/helper.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 detectImageTypeFromStream has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function detectImageTypeFromStream($stream) {
        $detectedType = false;

        \rewind($stream);
        $bytes = \fread($stream, 2);
Severity: Minor
Found in lib/private/legacy/image.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 isManipulation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function isManipulation($sql) {
        $selectOccurrence = \stripos($sql, 'SELECT');
        if ($selectOccurrence !== false && $selectOccurrence < 10) {
            return false;
        }
Severity: Minor
Found in lib/private/legacy/db.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 getGlobalStorageInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function getGlobalStorageInfo() {
        $quota = OC_Util::getUserQuota(\OCP\User::getUser());

        $rootInfo = \OC\Files\Filesystem::getFileInfo('', 'ext');
        $used = $rootInfo['size'];
Severity: Minor
Found in lib/private/legacy/helper.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 getShortFooter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getShortFooter() {
        if ($this->themeExist('getShortFooter')) {
            $footer = $this->theme->getShortFooter();
        } else {
            $footer  = '<a href="' . $this->getBaseUrl() . '" target="_blank" rel="noreferrer">' . $this->getEntity() . '</a>';
Severity: Minor
Found in lib/private/legacy/defaults.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 keySetPreparation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function keySetPreparation($path) {
        // If the file resides within a subdirectory, create it
        if (!$this->view->file_exists($path)) {
            $sub_dirs = \explode('/', \ltrim($path, '/'));
            $dir = '';
Severity: Minor
Found in lib/private/Encryption/Keys/Storage.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 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 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 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 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 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 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 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 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 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 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

Severity
Category
Status
Source
Language