owncloud/core

View on GitHub

Showing 4,504 of 4,504 total issues

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

    $('#shareapiExpireAfterNDaysUserShare').change(function() {
        var value = parseInt($(this).val(), 10)

        if (value <= 0 || isNaN(value)) {
            $(this).val(7);
Severity: Major
Found in settings/js/admin.js and 2 other locations - About 2 hrs to fix
settings/js/admin.js on lines 93..99
settings/js/admin.js on lines 105..111

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

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

        getDefaultExpireDateGroup: function(format) {
            format = format || false;
            defaultExpireDateGroup = parseInt(this.get('defaultExpireDateGroup'), 10);

            if (format) {
Severity: Major
Found in core/js/shareconfigmodel.js and 1 other location - About 2 hrs to fix
core/js/shareconfigmodel.js on lines 179..188

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

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 3 locations. Consider refactoring.
Open

    $('#shareapiExpireAfterNDaysGroupShare').change(function() {
        var value = parseInt($(this).val(), 10)

        if (value <= 0 || isNaN(value)) {
            $(this).val(7);
Severity: Major
Found in settings/js/admin.js and 2 other locations - About 2 hrs to fix
settings/js/admin.js on lines 81..87
settings/js/admin.js on lines 105..111

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

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

        getDefaultExpireDateRemote: function(format) {
            format = format || false;
            defaultExpireDateRemote = parseInt(this.get('defaultExpireDateRemote'), 10);

            if (format) {
Severity: Major
Found in core/js/shareconfigmodel.js and 1 other location - About 2 hrs to fix
core/js/shareconfigmodel.js on lines 151..160

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

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 3 locations. Consider refactoring.
Open

    $('#shareapiExpireAfterNDaysFederatedShare').change(function() {
        var value = parseInt($(this).val(), 10)

        if (value <= 0 || isNaN(value)) {
            $(this).val(7);
Severity: Major
Found in settings/js/admin.js and 2 other locations - About 2 hrs to fix
settings/js/admin.js on lines 81..87
settings/js/admin.js on lines 93..99

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

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 FedShareManager.php has 254 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @author Viktar Dubiniuk <dubiniuk@owncloud.com>
 *
 * @copyright Copyright (c) 2018, ownCloud GmbH
Severity: Minor
Found in apps/federatedfilesharing/lib/FedShareManager.php - About 2 hrs to fix

    File Router.php has 254 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * @author Bart Visscher <bartv@thisnet.nl>
     * @author Bernhard Posselt <dev@bernhard-posselt.com>
     * @author Joas Schilling <coding@schilljs.com>
    Severity: Minor
    Found in lib/private/Route/Router.php - About 2 hrs to fix

      Function _attachments has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      $.datepicker._attachments = function (input, inst) {
              var showOn, buttonText, buttonImage,
                  appendText = this._get(inst, "appendText"),
                  isRTL = this._get(inst, "isRTL");
      
      
      Severity: Minor
      Found in core/js/js.js - About 2 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 submit has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          submit: function() {
              var self = this;
              var data = this.data;
              var file = this.getFile();
      
      
      Severity: Minor
      Found in apps/files/js/file-upload.js - About 2 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 authenticate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function authenticate($linkItem, $password = null) {
              if ($password !== null) {
                  if ($linkItem['share_type'] == \OCP\Share::SHARE_TYPE_LINK) {
                      // Check Password
                      $newHash = '';
      Severity: Minor
      Found in apps/files_sharing/lib/Helper.php - About 2 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 formatItems has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function formatItems($items, $format, $parameters = null) {
              if ($format == self::FORMAT_SHARED_STORAGE) {
                  // Only 1 item should come through for this format call
                  $item = \array_shift($items);
                  return [
      Severity: Minor
      Found in apps/files_sharing/lib/ShareBackend/File.php - About 2 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 execute has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function execute(InputInterface $input, OutputInterface $output): int {
              $users = $input->getArgument('user_id');
              if (!empty($users)) {
                  foreach ($users as $user) {
                      if ($this->userManager->userExists($user)) {
      Severity: Minor
      Found in apps/files_trashbin/lib/Command/CleanUp.php - About 2 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 execute has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function execute(InputInterface $input, OutputInterface $output): int {
              $output->writeln("WARNING: incoming-shares:poll has been deprecated and replaced by periodic external shares cronjob. Please check Federated Cloud Sharing settings and documentation.");
              if ($this->externalMountProvider === null) {
                  $output->writeln("Polling is not possible when files_sharing app is disabled. Please enable it with 'occ app:enable files_sharing'");
                  return 1;
      Severity: Minor
      Found in apps/federatedfilesharing/lib/Command/PollIncomingShares.php - About 2 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 createTag has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          private function createTag($data, $contentType = 'application/json'): ISystemTag {
              if (\explode(';', $contentType)[0] === 'application/json') {
                  $data = \json_decode($data, true);
              } else {
                  throw new UnsupportedMediaType();
      Severity: Minor
      Found in apps/dav/lib/SystemTag/SystemTagPlugin.php - About 2 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 getSystemTagFileIds has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          private function getSystemTagFileIds($systemTagIds) {
              $resultFileIds = null;
      
              // check user permissions, if applicable
              if (!$this->isAdmin()) {
      Severity: Minor
      Found in apps/dav/lib/Connector/Sabre/FilesReportPlugin.php - About 2 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 expireOlderThanMaxForUser has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function expireOlderThanMaxForUser($uid) {
              $expiration = self::getExpiration();
              $threshold = $expiration->getMaxAgeAsTimestamp();
              $versions = self::getFileHelper()->getAllVersions($uid);
              if (!$threshold || !\array_key_exists('all', $versions)) {
      Severity: Minor
      Found in apps/files_versions/lib/Storage.php - About 2 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 execute has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function execute(InputInterface $input, OutputInterface $output): int {
              $pathOption = $input->getOption('path');
              $userName = $input->getOption('user');
      
              $scanUserFunction = function (IUser $user) use ($input, $output) {
      Severity: Minor
      Found in apps/files/lib/Command/VerifyChecksums.php - About 2 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 execute has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function execute(InputInterface $input, OutputInterface $output): int {
              $users = $input->getArgument('user_id');
              if (!empty($users)) {
                  foreach ($users as $user) {
                      if ($this->userManager->userExists($user)) {
      Severity: Minor
      Found in apps/files_versions/lib/Command/CleanUp.php - About 2 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 execute has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function execute(InputInterface $input, OutputInterface $output): int {
              $sourceUserObject = $this->userManager->get($input->getArgument('source-user'));
              $destinationUserObject = $this->userManager->get($input->getArgument('destination-user'));
              if ($sourceUserObject === null) {
                  $output->writeln("<error>Unknown source user $this->sourceUser</error>");
      Severity: Minor
      Found in apps/files/lib/Command/TransferOwnership.php - About 2 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 removeUser has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function removeUser($user) {
              $result = false;
              if ($this->emitter) {
                  $this->emitter->emit('\OC\Group', 'preRemoveUser', [$this, $user]);
              }
      Severity: Minor
      Found in lib/private/Group/Group.php - About 2 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

      Severity
      Category
      Status
      Source
      Language