owncloud/core

View on GitHub

Showing 4,504 of 4,504 total issues

Function getItemSharedWithUser has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getItemSharedWithUser($itemType, $itemSource, $user, $owner = null, $shareType = null) {
        $shares = [];
        $fileDependent = false;

        $where = 'WHERE';
Severity: Minor
Found in lib/private/Share/Share.php - About 3 hrs 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 parseHttpRangeHeader has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    private static function parseHttpRangeHeader($rangeHeaderPos, $fileSize) {
        $rArray=\explode(',', $rangeHeaderPos);
        $minOffset = 0;
        $ind = 0;

Severity: Minor
Found in lib/private/legacy/files.php - About 3 hrs 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 _output has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    private function _output($filePath = null, $mimeType = null) {
        if ($filePath) {
            if (!\file_exists(\dirname($filePath))) {
                \mkdir(\dirname($filePath), 0777, true);
            }
Severity: Minor
Found in lib/private/legacy/image.php - About 3 hrs 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 xmlToArray has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    protected function xmlToArray($xml) {
        if (!$xml->children()) {
            return (string)$xml;
        }

Severity: Minor
Found in lib/private/App/InfoParser.php - About 3 hrs 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 get has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    public static function get($dir, $files, $params = null) {
        $view = \OC\Files\Filesystem::getView();

        if (!\is_array($files)) {
            // "files" contains a string with a filename
Severity: Minor
Found in lib/private/legacy/files.php - About 3 hrs 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 checkAppsIntegrity has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    public static function checkAppsIntegrity($data, $extractDir, $path, $isShipped = false) {
        $l = \OC::$server->getL10N('lib');
        //load the info.xml file of the app
        if (!\is_file($extractDir.'/appinfo/info.xml')) {
            //try to find it in a subdir
Severity: Minor
Found in lib/private/Installer.php - About 3 hrs 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 postAvatar has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    public function postAvatar($path) {
        $userId = $this->userSession->getUser()->getUID();
        $files = $this->request->getUploadedFile('files');
        $tmpImage = null;

Severity: Minor
Found in core/Controller/AvatarController.php - About 3 hrs 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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        if ($reshares === false) {
            //Special case for old shares created via the web UI
            $or1 = $qb->expr()->andX(
                $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)),
                $qb->expr()->isNull('uid_initiator')
Severity: Major
Found in apps/federatedfilesharing/lib/FederatedShareProvider.php and 1 other location - About 3 hrs to fix
apps/federatedfilesharing/lib/FederatedShareProvider.php on lines 628..648

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 157.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        if ($reshares === false) {
            //Special case for old shares created via the web UI
            $or1 = $qb->expr()->andX(
                $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)),
                $qb->expr()->isNull('uid_initiator')
Severity: Major
Found in apps/federatedfilesharing/lib/FederatedShareProvider.php and 1 other location - About 3 hrs to fix
apps/federatedfilesharing/lib/FederatedShareProvider.php on lines 679..699

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 157.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

File sharedialoglinkshareview.js has 322 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright (c) 2015
 *
 * This file is licensed under the Affero General Public License version 3
 * or later.
Severity: Minor
Found in core/js/sharedialoglinkshareview.js - About 3 hrs to fix

    File QueryBuilder.php has 322 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * @author Joas Schilling <coding@schilljs.com>
     * @author Robin Appelman <icewind@owncloud.com>
     * @author Thomas Müller <thomas.mueller@tmit.eu>
    Severity: Minor
    Found in lib/private/DB/QueryBuilder/QueryBuilder.php - About 3 hrs to fix

      Method createFileChunked has 93 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function createFileChunked($data) {
              list($path, $name) = \Sabre\Uri\split($this->path);
      
              $info = \OC_FileChunking::decodeName($name);
              if (empty($info)) {
      Severity: Major
      Found in apps/dav/lib/Connector/Sabre/File.php - About 3 hrs to fix

        Method showLoginForm has 93 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function showLoginForm($user, $redirect_url, $remember_login) {
                // check if there is apache auth backend available and try to obtain session,
                // if apache backend not registered or failed to login, proceed with show login form
                if ($this->handleApacheAuth()) {
                    // apache auth was completed server-side and there is active session,
        Severity: Major
        Found in core/Controller/LoginController.php - About 3 hrs to fix

          File search.js has 321 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /**
           * ownCloud - core
           *
           * This file is licensed under the Affero General Public License version 3 or
           * later. See the COPYING file.
          Severity: Minor
          Found in core/search/js/search.js - About 3 hrs to fix

            File pt_PT.js has 320 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            OC.L10N.register(
                "settings",
                {
                "No user supplied" : "Nenhum utilizador especificado",
                "Authentication error" : "Erro de autenticação",
            Severity: Minor
            Found in settings/l10n/pt_PT.js - About 3 hrs to fix

              Function _triggerGroupEdit has 92 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  _triggerGroupEdit: function($td, isSubadminSelect) {
                      var $groupsListContainer = $td.find('.groupsListContainer');
                      var placeholder = $groupsListContainer.attr('data-placeholder') || t('settings', 'no group');
                      var user = UserList.getUID($td);
                      var checked = _.keys($td.data('groups')) || [];
              Severity: Major
              Found in settings/js/users/users.js - About 3 hrs to fix

                Method setMailAddress has 92 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function setMailAddress($id, $mailAddress) {
                        $userId = $this->userSession->getUser()->getUID();
                        $user = $this->userManager->get($id);
                
                        if ($userId !== $id
                Severity: Major
                Found in settings/Controller/UsersController.php - About 3 hrs to fix

                  Method getCapabilities has 92 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function getCapabilities() {
                          $res = [];
                  
                          if ($this->config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') {
                              $res['api_enabled'] = false;
                  Severity: Major
                  Found in apps/files_sharing/lib/Capabilities.php - About 3 hrs to fix

                    Method scanFile has 92 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) {
                            // only proceed if $file is not a partial file nor a blacklisted file
                            if (!self::isPartialFile($file) and !Filesystem::isFileBlacklisted($file)) {
                                //acquire a lock
                                if ($lock && $this->storage->instanceOfStorage(ILockingStorage::class)) {
                    Severity: Major
                    Found in lib/private/Files/Cache/Scanner.php - About 3 hrs to fix

                      CardDavBackend has 30 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      class CardDavBackend implements BackendInterface, SyncSupport {
                          /** @var Principal */
                          private $principalBackend;
                      
                          /** @var string */
                      Severity: Minor
                      Found in apps/dav/lib/CardDAV/CardDavBackend.php - About 3 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language