owncloud/core

View on GitHub
apps/files_external/js/statusmanager.js

Summary

Maintainability
F
3 days
Test Coverage

File statusmanager.js has 466 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * ownCloud
 *
 * @author Juan Pablo VillafaƱez Ramos <jvillafanez@owncloud.com>
 * @author Jesus Macias Portela <jesus@owncloud.com>
Severity: Minor
Found in apps/files_external/js/statusmanager.js - About 7 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 showCredentialsDialog has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        showCredentialsDialog: function (mountPoint, mountData) {
            var template = Handlebars.compile(OCA.External.StatusManager.credentialsDialogTemplate);
            var dialog = $(template({
                credentials_text: t('files_external', 'Please enter the credentials for the {mount} mount', {
                    'mount': mountPoint
    Severity: Major
    Found in apps/files_external/js/statusmanager.js - About 2 hrs to fix

      Function getMountStatusForMount has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          getMountStatusForMount: function (mountData, afterCallback) {
              var self = this;
              if (typeof afterCallback !== 'function' || self.isGetMountStatusRunning) {
                  return $.Deferred().resolve();
              }
      Severity: Major
      Found in apps/files_external/js/statusmanager.js - About 2 hrs to fix

        Function launchFullConnectivityCheckOneByOne has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            launchFullConnectivityCheckOneByOne: function () {
                var self = this;
                this.getMountPointList(function (list) {
                    // check if we have a list first
                    if (list === undefined && !self.emptyWarningShown) {
        Severity: Minor
        Found in apps/files_external/js/statusmanager.js - About 1 hr to fix

          Function getMountPointList has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              getMountPointList: function (afterCallback) {
                  var self = this;
                  if (typeof afterCallback !== 'function' || self.isGetMountPointListRunning) {
                      return;
                  }
          Severity: Minor
          Found in apps/files_external/js/statusmanager.js - About 1 hr to fix

            Function manageMountPointError has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                manageMountPointError: function (name) {
                    this.getMountStatus($.proxy(function (allMountStatus) {
                        if (allMountStatus.hasOwnProperty(name) && allMountStatus[name].status > 0 && allMountStatus[name].status < 7) {
                            var mountData = allMountStatus[name];
                            if (mountData.type === "system") {
            Severity: Minor
            Found in apps/files_external/js/statusmanager.js - 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 manageMountPointError has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                manageMountPointError: function (name) {
                    this.getMountStatus($.proxy(function (allMountStatus) {
                        if (allMountStatus.hasOwnProperty(name) && allMountStatus[name].status > 0 && allMountStatus[name].status < 7) {
                            var mountData = allMountStatus[name];
                            if (mountData.type === "system") {
            Severity: Minor
            Found in apps/files_external/js/statusmanager.js - About 1 hr to fix

              Function apply has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      var apply = function () {
                          var username = dialog.find('[name=username]').val();
                          var password = dialog.find('[name=password]').val();
                          var endpoint = OC.generateUrl('apps/files_external/userglobalstorages/{id}', {
                              id: mountData.id
              Severity: Minor
              Found in apps/files_external/js/statusmanager.js - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                                                if (OC.isUserAdmin()) {
                                                    OC.redirect(OC.generateUrl('/settings/admin?sectionid=storage'));
                                                }
                                                else {
                                                    OC.redirect(OC.generateUrl('/settings/personal?sectionid=storage'));
                Severity: Major
                Found in apps/files_external/js/statusmanager.js - About 45 mins to fix

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

                      processMountStatusIndividual: function (mountData, mountStatus) {
                  
                          var mountPoint = mountData.mount_point;
                          if (mountStatus.status > 0) {
                              var trElement = FileList.findFileEl(OCA.External.StatusManager.Utils.jqSelEscape(mountPoint));
                  Severity: Minor
                  Found in apps/files_external/js/statusmanager.js - 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

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

                          icon.each(function () {
                              var thisElement = $(this);
                              if (thisElement.data('oldImage') === undefined) {
                                  thisElement.data('oldImage', thisElement.css('background-image'));
                              }
                  Severity: Major
                  Found in apps/files_external/js/statusmanager.js and 1 other location - About 1 hr to fix
                  apps/files_external/js/statusmanager.js on lines 488..493

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

                  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

                          trFolder.each(function () {
                              var thisElement = $(this);
                              if (thisElement.data('oldbgcolor') === undefined) {
                                  thisElement.data('oldbgcolor', thisElement.css('background-color'));
                              }
                  Severity: Major
                  Found in apps/files_external/js/statusmanager.js and 1 other location - About 1 hr to fix
                  apps/files_external/js/statusmanager.js on lines 496..501

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

                  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

                                      var queueElement = {
                                          funcName: $.proxy(self.getMountStatusForMount, self),
                                          funcArgs: [value,
                                              $.proxy(self.processMountStatusIndividual, self)]
                                      };
                  Severity: Minor
                  Found in apps/files_external/js/statusmanager.js and 1 other location - About 35 mins to fix
                  apps/files_external/js/statusmanager.js on lines 334..338

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

                  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

                              var queueElement = {
                                  funcName: $.proxy(self.getMountStatusForMount, self),
                                  funcArgs: [value,
                                      $.proxy(self.processMountStatusIndividual, self)]
                              };
                  Severity: Minor
                  Found in apps/files_external/js/statusmanager.js and 1 other location - About 35 mins to fix
                  apps/files_external/js/statusmanager.js on lines 287..291

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

                  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

                  There are no issues that match your filters.

                  Category
                  Status