owncloud/core

View on GitHub

Showing 4,504 of 4,504 total issues

Function getAppsFromMarket has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getAppsFromMarket(IOutput $output, $appList, $event) {
        $failedApps = [];
        foreach ($appList as $app) {
            $output->info("Fetching app from market: $app");
            try {
Severity: Minor
Found in lib/private/Repair/Apps.php - About 1 hr 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 getAllSharesBy has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function getAllSharesBy($userId, $shareTypes, $nodeIDs, $reshares = false) {
        // This function requires at least 1 node (parent folder)
        if (empty($nodeIDs)) {
            throw new \InvalidArgumentException('Array of nodeIDs empty');
        }
Severity: Minor
Found in lib/private/Share20/Manager.php - About 1 hr 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 convertAddresses has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function convertAddresses($addresses) {
        if (!\function_exists('idn_to_ascii')) {
            return $addresses;
        }

Severity: Minor
Found in lib/private/Mail/Message.php - About 1 hr 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 main has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public static function main($controllerName, $methodName, DIContainer $container, array $urlParams = null) {
        if ($urlParams !== null) {
            $container['OCP\\IRequest']->setUrlParameters($urlParams);
        } elseif (isset($container['urlParams']) && $container['urlParams'] !== null) {
            $container['OCP\\IRequest']->setUrlParameters($container['urlParams']);
Severity: Minor
Found in lib/private/AppFramework/App.php - About 1 hr 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 addUseNameToBlackList has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function addUseNameToBlackList($name, $alias) {
        $name = \strtolower($name);
        $alias = \strtolower($alias);

        foreach ($this->blackListedClassNames as $blackListedAlias => $blackListedClassName) {
Severity: Minor
Found in lib/private/App/CodeChecker/NodeVisitor.php - About 1 hr 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 getAllApps has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getAllApps() {
        $apps = [];

        foreach (OC::$APPSROOTS as $apps_dir) {
            if (!\is_readable($apps_dir['path'])) {
Severity: Minor
Found in lib/private/legacy/app.php - About 1 hr 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 downloadApp has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public static function downloadApp($data = []) {
        $l = \OC::$server->getL10N('lib');

        if (!isset($data['source'])) {
            throw new \Exception($l->t("No source specified when installing app"));
Severity: Minor
Found in lib/private/Installer.php - About 1 hr 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 decryptAllUsersFiles has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function decryptAllUsersFiles($user = '') {
        $this->output->writeln("\n");

        $progress = new ProgressBar($this->output);
        $progress->setFormat(" %message% \n [%bar%]");
Severity: Minor
Found in lib/private/Encryption/DecryptAll.php - About 1 hr 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 setupBackends has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public static function setupBackends() {
        OC_App::loadApps(['prelogin']);
        $backends = \OC::$server->getSystemConfig()->getValue('user_backends', []);
        if (isset($backends['default']) && !$backends['default']) {
            // clear default backends
Severity: Minor
Found in lib/private/legacy/user.php - About 1 hr 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 syncHome has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function syncHome(Account $a, UserInterface $backend) {
        // Fallback for backends that dont yet use the new interfaces
        $providesHome = $backend instanceof IProvidesHomeBackend || $backend->implementsActions(\OC_User_Backend::GET_HOME);
        $uid = $a->getUserId();
        // Log when the backend returns a string that is a different home to the current value
Severity: Minor
Found in lib/private/User/SyncService.php - About 1 hr 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 search has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function search($query) {
        $files = Filesystem::search($query);
        $results = [];
        // edit results
        foreach ($files as $fileData) {
Severity: Minor
Found in lib/private/Search/Provider/File.php - About 1 hr 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 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function execute(InputInterface $input, OutputInterface $output): int {
        $confirmed = $input->getOption('continue');
        if (($confirmed !== 'yes') && ($confirmed !== 'no')) {
            $output->writeln('Continue can accept either yes or no');
            return 2;
Severity: Minor
Found in core/Command/Encryption/DecryptAll.php - About 1 hr 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 validateArray has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function validateArray($array) {
        $arrayKeys = \array_keys($array);
        $additionalKeys = \array_diff($arrayKeys, $this->validRootKeys);
        $commonKeys = \array_intersect($arrayKeys, $this->validRootKeys);
        if (!empty($additionalKeys)) {
Severity: Minor
Found in core/Command/Config/Import.php - About 1 hr 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 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function execute(InputInterface $input, OutputInterface $output): int {
        if ($input->getOption('list')) {
            $backends = $this->userManager->getBackends();
            foreach ($backends as $backend) {
                $output->writeln(\get_class($backend));
Severity: Minor
Found in core/Command/User/SyncBackend.php - About 1 hr 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 (
                // legacy
                $newPermissions === (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE) ||
                // correct
                $newPermissions === (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE)
Severity: Major
Found in apps/files_sharing/lib/Controller/Share20OcsController.php and 1 other location - About 1 hr to fix
apps/files_sharing/lib/Controller/Share20OcsController.php on lines 906..916

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

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

        try {
            $share = $this->shareManager->createShare($share);
            /**
             * If auto accept enabled by admin and it is a group share,
             * create sub-share for auto accept disabled users in pending state.
Severity: Major
Found in apps/files_sharing/lib/Controller/Share20OcsController.php and 1 other location - About 1 hr to fix
apps/files_sharing/lib/Controller/Share20OcsController.php on lines 958..967

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

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 ($includesCreatePermission) {
                if (!$this->shareManager->shareApiLinkAllowPublicUpload()) {
                    $share->getNode()->unlock(ILockingProvider::LOCK_SHARED);
                    return new Result(null, 403, $this->l->t('Public upload disabled by the administrator'));
                }
Severity: Major
Found in apps/files_sharing/lib/Controller/Share20OcsController.php and 1 other location - About 1 hr to fix
apps/files_sharing/lib/Controller/Share20OcsController.php on lines 887..902

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

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

    public function __construct(
        IConfig $config = null,
        IUserManager $userManager = null,
        TrashExpiryManager $trashExpiryManager = null
    ) {
Severity: Major
Found in apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php and 1 other location - About 1 hr to fix
apps/files/lib/BackgroundJob/ScanFiles.php on lines 54..69

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

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

    public function __construct(
        IConfig $config = null,
        IUserManager $userManager = null,
        ILogger $logger = null
    ) {
Severity: Major
Found in apps/files/lib/BackgroundJob/ScanFiles.php and 1 other location - About 1 hr to fix
apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php on lines 59..74

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

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

        try {
            $share = $this->shareManager->updateShare($share);
        } catch (GenericShareException $e) {
            $code = $e->getCode() === 0 ? 403 : $e->getCode();
            $share->getNode()->unlock(ILockingProvider::LOCK_SHARED);
Severity: Major
Found in apps/files_sharing/lib/Controller/Share20OcsController.php and 1 other location - About 1 hr to fix
apps/files_sharing/lib/Controller/Share20OcsController.php on lines 584..608

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

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