owncloud/core

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

Summary

Maintainability
F
1 wk
Test Coverage

File settings.js has 1138 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright (c) 2014
 *
 * This file is licensed under the Affero General Public License version 3
 * or later.
Severity: Major
Found in apps/files_external/js/settings.js - About 2 days to fix

    Function newStorage has 114 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        newStorage: function(storageConfig, onCompletion) {
            var mountPoint = storageConfig.mountPoint;
            var backend = this._allBackends[storageConfig.backend];
            var isInvalidAuth = false;
    
    
    Severity: Major
    Found in apps/files_external/js/settings.js - About 4 hrs to fix

      Function addSelect2 has 109 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function addSelect2 ($elements, userListLimit) {
          if (!$elements.length) {
              return;
          }
          $elements.select2({
      Severity: Major
      Found in apps/files_external/js/settings.js - About 4 hrs to fix

        Function getStorageConfig has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            getStorageConfig: function($tr) {
                var storageId = $tr.data('id');
                if (!storageId) {
                    // new entry
                    storageId = null;
        Severity: Major
        Found in apps/files_external/js/settings.js - About 2 hrs to fix

          Function loadStorages has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              loadStorages: function() {
                  var self = this;
                  var ajaxRequests = [];
          
                  if (this._isPersonal) {
          Severity: Major
          Found in apps/files_external/js/settings.js - About 2 hrs to fix

            Function getAuthUrl has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            OCA.External.Settings.OAuth2.getAuthUrl = function (backendUrl, data) {
                var $tr = data['tr'];
                var configured = $tr.find('[data-parameter="configured"]');
                var token = $tr.find('.configuration [data-parameter="token"]');
            
            
            Severity: Minor
            Found in apps/files_external/js/settings.js - About 1 hr to fix

              Function _showMountOptionsDropdown has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  _showMountOptionsDropdown: function($tr) {
                      if (this._preventNextDropdown) {
                          // prevented because the click was on the toggle
                          this._preventNextDropdown = false;
                          return;
              Severity: Minor
              Found in apps/files_external/js/settings.js - About 1 hr to fix

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

                    saveStorageConfig:function($tr, callback, concurrentTimer) {
                        var self = this;
                        var storage = this.getStorageConfig($tr);
                        if (!storage || !storage.validate()) {
                            return false;
                Severity: Minor
                Found in apps/files_external/js/settings.js - About 1 hr to fix

                  Function verifyCode has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  OCA.External.Settings.OAuth2.verifyCode = function (backendUrl, data) {
                      var $tr = data['tr'];
                      var configured = $tr.find('[data-parameter="configured"]');
                      var token = $tr.find('.configuration [data-parameter="token"]');
                      var statusSpan = $tr.find('.status span');
                  Severity: Minor
                  Found in apps/files_external/js/settings.js - About 1 hr to fix

                    Function writeParameterInput has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        writeParameterInput: function($td, parameter, placeholder, classes) {
                            var hasFlag = function(flag) {
                                return (placeholder.flags & flag) === flag;
                            };
                            classes = $.isArray(classes) ? classes : [];
                    Severity: Minor
                    Found in apps/files_external/js/settings.js - About 1 hr to fix

                      Function initSelection has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              initSelection: function(element, callback) {
                                  var storageConfig = element.closest('tr').data('storageConfig');
                                  $.when(
                                      $.ajax(OC.generateUrl('apps/files_external/applicable/users'), {
                                          type: 'POST',
                      Severity: Minor
                      Found in apps/files_external/js/settings.js - About 1 hr to fix

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

                                        if (d1[0].status === 'success') {
                                            $.each(d1[0].users, function(user, displayname) {
                                                results.push({name:'u:'+user, displayname:displayname, type:'user'});
                                            });
                                        } else {
                        Severity: Major
                        Found in apps/files_external/js/settings.js and 1 other location - About 2 hrs to fix
                        apps/files_external/js/settings.js on lines 160..166

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

                        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 (d2[0].status === 'success') {
                                            $.each(d2[0].groups, function(group, displayname) {
                                                results.push({name:'g:'+group, displayname:displayname, type:'group'});
                                            });
                                        } else {
                        Severity: Major
                        Found in apps/files_external/js/settings.js and 1 other location - About 2 hrs to fix
                        apps/files_external/js/settings.js on lines 153..159

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

                        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

                                        $.ajax(OC.generateUrl('apps/files_external/applicable/groups'), {
                                            type: 'POST',
                                            contentType: 'application/json',
                                            data: JSON.stringify({'groups' : storageConfig.applicableGroups}),
                                            dataType: 'json'
                        Severity: Major
                        Found in apps/files_external/js/settings.js and 1 other location - About 1 hr to fix
                        apps/files_external/js/settings.js on lines 139..144

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

                        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

                                        $.ajax(OC.generateUrl('apps/files_external/applicable/users'), {
                                            type: 'POST',
                                            contentType: 'application/json',
                                            data: JSON.stringify({'users' : storageConfig.applicableUsers}),
                                            dataType: 'json'
                        Severity: Major
                        Found in apps/files_external/js/settings.js and 1 other location - About 1 hr to fix
                        apps/files_external/js/settings.js on lines 145..150

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

                        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 (storageConfig.applicableUsers) {
                                    applicable = applicable.concat(
                                        _.map(storageConfig.applicableUsers, function(user) {
                                            return 'u:'+user;
                                        })
                        Severity: Minor
                        Found in apps/files_external/js/settings.js and 1 other location - About 50 mins to fix
                        apps/files_external/js/settings.js on lines 978..984

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

                        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 (storageConfig.applicableGroups) {
                                    applicable = applicable.concat(
                                        _.map(storageConfig.applicableGroups, function(group) {
                                            return 'g:'+group;
                                        })
                        Severity: Minor
                        Found in apps/files_external/js/settings.js and 1 other location - About 50 mins to fix
                        apps/files_external/js/settings.js on lines 971..977

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

                        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 (placeholder.type === MountConfigListView.ParameterTypes.PASSWORD) {
                                    newElement = $('<input type="password" class="'+classes.join(' ')+'" data-parameter="'+parameter+'" placeholder="'+ trimmedPlaceholder+'" autocomplete="off" />');
                                } else if (placeholder.type === MountConfigListView.ParameterTypes.BOOLEAN) {
                        Severity: Minor
                        Found in apps/files_external/js/settings.js and 1 other location - About 35 mins to fix
                        apps/files_external/js/settings.js on lines 1119..1121

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

                        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

                                } else {
                                    newElement = $('<input type="text" class="'+classes.join(' ')+'" data-parameter="'+parameter+'" placeholder="'+ trimmedPlaceholder+'" />');
                                }
                        Severity: Minor
                        Found in apps/files_external/js/settings.js and 1 other location - About 35 mins to fix
                        apps/files_external/js/settings.js on lines 1112..1114

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

                        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

                                this.$el.on('click', 'td.remove>img', function() {
                                    self.deleteStorageConfig($(this).closest('tr'));
                                });
                        Severity: Minor
                        Found in apps/files_external/js/settings.js and 2 other locations - About 30 mins to fix
                        apps/files_external/js/settings.js on lines 744..746
                        apps/files_external/js/settings.js on lines 752..754

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

                        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

                                this.$el.on('click', 'td.mountOptionsToggle>img', function() {
                                    self._showMountOptionsDropdown($(this).closest('tr'));
                                });
                        Severity: Minor
                        Found in apps/files_external/js/settings.js and 2 other locations - About 30 mins to fix
                        apps/files_external/js/settings.js on lines 744..746
                        apps/files_external/js/settings.js on lines 748..750

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

                        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

                                this.$el.on('click', '.status>span', function() {
                                    self.recheckStorageConfig($(this).closest('tr'));
                                });
                        Severity: Minor
                        Found in apps/files_external/js/settings.js and 2 other locations - About 30 mins to fix
                        apps/files_external/js/settings.js on lines 748..750
                        apps/files_external/js/settings.js on lines 752..754

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

                        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