owncloud/core

View on GitHub

Showing 4,504 of 4,504 total issues

File FilesPlugin.php has 303 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @author Björn Schießle <bjoern@schiessle.org>
 * @author Joas Schilling <coding@schilljs.com>
 * @author Lukas Reschke <lukas@statuscode.ch>
Severity: Minor
Found in apps/dav/lib/Connector/Sabre/FilesPlugin.php - About 3 hrs to fix

    File TransferOwnership.php has 303 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * @author Carla Schroder <carla@owncloud.com>
     * @author Joas Schilling <coding@schilljs.com>
     * @author Thomas Müller <thomas.mueller@tmit.eu>
    Severity: Minor
    Found in apps/files/lib/Command/TransferOwnership.php - About 3 hrs to fix

      File Encryption.php has 303 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * @author Björn Schießle <bjoern@schiessle.org>
       * @author jknockaert <jasper@knockaert.nl>
       * @author Lukas Reschke <lukas@statuscode.ch>
      Severity: Minor
      Found in lib/private/Files/Stream/Encryption.php - About 3 hrs to fix

        Function getMountStatusForMount has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            getMountStatusForMount: function (mountData, afterCallback) {
                var self = this;
                if (typeof afterCallback !== 'function' || self.isGetMountStatusRunning) {
                    return $.Deferred().resolve();
                }
        Severity: Minor
        Found in apps/files_external/js/statusmanager.js - 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 getFailedIntegrityCheckFiles has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getFailedIntegrityCheckFiles(): DataDisplayResponse {
                if (!$this->checker->isCodeCheckEnforced()) {
                    return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.');
                }
        
        
        Severity: Minor
        Found in settings/Controller/CheckSetupController.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 getCapabilities has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getCapabilities() {
                $res = [];
        
                if ($this->config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') {
                    $res['api_enabled'] = false;
        Severity: Minor
        Found in apps/files_sharing/lib/Capabilities.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 auth has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            private function auth(RequestInterface $request, ResponseInterface $response) {
                $forcedLogout = false;
                if (!$this->request->passesCSRFCheck() &&
                    $this->requiresCSRFCheck()) {
                    // In case of a fail with POST we need to recheck the credentials
        Severity: Minor
        Found in apps/dav/lib/Connector/Sabre/Auth.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 getMountsForUser has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getMountsForUser(IUser $user) {
                $loader = $this->loader;
                $mounts = \array_map(function (IMountProvider $provider) use ($user, $loader) {
                    return $provider->getMountsForUser($user, $loader);
                }, $this->providers);
        Severity: Minor
        Found in lib/private/Files/Config/MountProviderCollection.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 run has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            public function run(IOutput $output) {
                if ($this->config->getSystemValue('has_internet_connection', true) !== true) {
                    $link = $this->defaults->buildDocLinkToKey('admin-marketplace-apps');
                    $output->info('No internet connection available - no app updates will be taken from the marketplace.');
                    $output->info("How to update apps in such situation please see $link");
        Severity: Minor
        Found in lib/private/Repair/Apps.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 unshareFromSelf has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function unshareFromSelf($itemType, $itemOrigin, $originIsSource = false) {
                $originType = ($originIsSource) ? 'source' : 'target';
                $uid = \OCP\User::getUser();
        
                if ($itemType === 'file' || $itemType === 'folder') {
        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 generalChecks has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function generalChecks(\OCP\Share\IShare $share) {
                if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
                    // We expect a valid user as sharedWith for user shares
                    if (!$this->userManager->userExists($share->getSharedWith())) {
                        throw new \InvalidArgumentException('SharedWith is not a valid user');
        Severity: Minor
        Found in lib/private/Share20/Manager.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 userCreateChecks has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function userCreateChecks(\OCP\Share\IShare $share) {
                $userTypeHelper = new UserTypeHelper();
                $isGuestUser = $userTypeHelper->isGuestUser($share->getSharedWith());
                // Check if we can share with group members only
                // We still should be able to share with guest user even when it's not a group member
        Severity: Minor
        Found in lib/private/Share20/Manager.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 initialize has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function initialize() {
                $loadedExtensions = \get_loaded_extensions();
                $packages = [];
        
                // Extensions scanning
        Severity: Minor
        Found in lib/private/App/PlatformRepository.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 linkTo has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            public function linkTo($app, $file, $args = []) {
                $frontControllerActive = (\getenv('front_controller_active') === 'true');
                $webRoot = $this->environmentHelper->getWebRoot();
        
                if ($app != '') {
        Severity: Minor
        Found in lib/private/URLGenerator.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 analyzeLibraries has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            private function analyzeLibraries(array $dependencies) {
                $missing = [];
                if (!isset($dependencies['lib'])) {
                    return $missing;
                }
        Severity: Minor
        Found in lib/private/App/DependencyAnalyzer.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 install has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            public function install($options) {
                $l = $this->l10n;
        
                $error = [];
                $dbType = $options['dbtype'];
        Severity: Minor
        Found in lib/private/Setup.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 removeListener has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            public function removeListener($scope = null, $method = null, callable $callback = null) {
                $names = [];
                $allNames = \array_keys($this->listeners);
                if ($scope and $method) {
                    $name = $scope . '::' . $method;
        Severity: Minor
        Found in lib/private/Hooks/EmitterTrait.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 changeSchema has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            public function changeSchema(Schema $schema, array $options) {
                $prefix = $options['tablePrefix'];
        
                if (!$schema->hasTable("{$prefix}addressbookchanges")) {
                    $addressBookChangesTable = $schema->createTable("{$prefix}addressbookchanges");
        Severity: Minor
        Found in core/Migrations/Version20170101010100.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

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

                        _.map(filteredAttribute.incompatibleAttributes, function(incompatibleAttribute) {
                            _.map(filteredAttributes, function(checkAttr) {
                                if (incompatibleAttribute.scope === checkAttr.scope &&
                                    incompatibleAttribute.key === checkAttr.key &&
                                    incompatibleAttribute.enabled === checkAttr.enabled) {
        Severity: Major
        Found in core/js/shareitemmodel.js and 1 other location - About 3 hrs to fix
        core/js/shareitemmodel.js on lines 926..934

        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 100.

        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

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

                if (user.lastLogin === 0 && user.isGuest !== true) {
                    var resendImage = $('<img class="action">').attr({
                        src: OC.imagePath('core', 'actions/mail')
                    });
                    var resendLink = $('<a class="action resendInvitationEmail">')
        Severity: Major
        Found in settings/js/users/users.js and 1 other location - About 3 hrs to fix
        settings/js/users/users.js on lines 131..141

        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 100.

        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

        Severity
        Category
        Status
        Source
        Language