owncloud/core

View on GitHub
core/js/sharedialogview.js

Summary

Maintainability
F
4 days
Test Coverage

File sharedialogview.js has 526 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright (c) 2015
 *
 * This file is licensed under the Affero General Public License version 3
 * or later.
Severity: Major
Found in core/js/sharedialogview.js - About 1 day to fix

    Function autocompleteHandler has 145 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            autocompleteHandler: function (search, response) {
                var view = this;
                var $loading = this.$el.find('.shareWithLoading');
                var trimmedSearch = search.term.trim();
                $loading.removeClass('hidden');
    Severity: Major
    Found in core/js/sharedialogview.js - About 5 hrs to fix

      Function _getUsersForBatchAction has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              _getUsersForBatchAction: function(search) {
                  var view = this;
                  var foundUsers = [];
                  var notFound = [];
                  var promises = [];
      Severity: Minor
      Found in core/js/sharedialogview.js - About 2 hrs to fix

        Function autocompleteRenderItem has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                autocompleteRenderItem: function(ul, item) {
                    var text = item.label;
                    var showIcon = false;
                    var iconClass = "";
                    var typeInfo = t('core', 'User');
        Severity: Minor
        Found in core/js/sharedialogview.js - About 1 hr to fix

          Function initialize has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  initialize: function(options) {
                      var view = this;
          
                      this.model.on('fetchError', function() {
                          OC.Notification.showTemporary(t('core', 'Share details could not be loaded for this item.'));
          Severity: Minor
          Found in core/js/sharedialogview.js - About 1 hr to fix

            Function render has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    render: function() {
                        var baseTemplate = this._getTemplate('base', TEMPLATE_BASE);
            
                        this.$el.html(baseTemplate({
                            cid: this.cid,
            Severity: Minor
            Found in core/js/sharedialogview.js - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                                          } else if (share.share_type === OC.Share.SHARE_TYPE_REMOTE) {
                                              remotesLength = remotes.length;
                                              for (j = 0; j < remotesLength; j++) {
                                                  if (remotes[j].value.shareWith === share.share_with) {
                                                      remotes.splice(j, 1);
              Severity: Major
              Found in core/js/sharedialogview.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                                    if (users[j].value.shareWith === share.share_with) {
                                                        users.splice(j, 1);
                                                        break;
                                                    }
                Severity: Major
                Found in core/js/sharedialogview.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                                          if (res.found[i].shareWith === OC.currentUser) {
                                                              res.found.splice(i, 1);
                                                              continue;
                                                          }
                  Severity: Major
                  Found in core/js/sharedialogview.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                    for (j = 0; j < groupsLength; j++) {
                                                        if (groups[j].value.shareWith === share.share_with) {
                                                            groups.splice(j, 1);
                                                            break;
                                                        }
                    Severity: Major
                    Found in core/js/sharedialogview.js - About 45 mins to fix

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

                          var TEMPLATE_AUTOCOMPLETE_ITEM =
                              '<li class="{{shareTypeClass}}">' +
                                  '<a>' +
                                      '<div class="share-autocomplete-item">' +
                                          '{{#if showAvatar}}' +
                      Severity: Major
                      Found in core/js/sharedialogview.js and 1 other location - About 2 hrs to fix
                      apps/files/js/mainfileinfodetailview.js on lines 12..31

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

                      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

                                                  } else if (share.share_type === OC.Share.SHARE_TYPE_REMOTE) {
                                                      remotesLength = remotes.length;
                                                      for (j = 0; j < remotesLength; j++) {
                                                          if (remotes[j].value.shareWith === share.share_with) {
                                                              remotes.splice(j, 1);
                      Severity: Major
                      Found in core/js/sharedialogview.js and 2 other locations - About 2 hrs to fix
                      core/js/sharedialogview.js on lines 247..271
                      core/js/sharedialogview.js on lines 255..271

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

                      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

                                                  if (share.share_type === OC.Share.SHARE_TYPE_USER) {
                                                      usersLength = users.length;
                                                      for (j = 0; j < usersLength; j++) {
                                                          if (users[j].value.shareWith === share.share_with) {
                                                              users.splice(j, 1);
                      Severity: Major
                      Found in core/js/sharedialogview.js and 2 other locations - About 2 hrs to fix
                      core/js/sharedialogview.js on lines 255..271
                      core/js/sharedialogview.js on lines 263..271

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

                      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

                                                  } else if (share.share_type === OC.Share.SHARE_TYPE_GROUP) {
                                                      groupsLength = groups.length;
                                                      for (j = 0; j < groupsLength; j++) {
                                                          if (groups[j].value.shareWith === share.share_with) {
                                                              groups.splice(j, 1);
                      Severity: Major
                      Found in core/js/sharedialogview.js and 2 other locations - About 2 hrs to fix
                      core/js/sharedialogview.js on lines 247..271
                      core/js/sharedialogview.js on lines 263..271

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

                      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