owncloud/core

View on GitHub
core/js/share.js

Summary

Maintainability
F
3 days
Test Coverage

Function updateIcons has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

    updateIcons:function(itemType, fileList){
        var item;
        var $fileList;
        var currentDir;
        if (!fileList && OCA.Files) {
Severity: Minor
Found in core/js/share.js - About 1 day 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

File share.js has 326 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global escapeHTML */

/**
 * @namespace
 */
Severity: Minor
Found in core/js/share.js - About 3 hrs to fix

    Function markFileAsShared has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        markFileAsShared: function($tr, hasShares, hasLink) {
            var action = $tr.find('.fileactions .action[data-action="Share"]');
            var type = $tr.data('type');
            var icon = action.find('.icon');
            var message;
    Severity: Minor
    Found in core/js/share.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 updateIcons has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        updateIcons:function(itemType, fileList){
            var item;
            var $fileList;
            var currentDir;
            if (!fileList && OCA.Files) {
    Severity: Major
    Found in core/js/share.js - About 2 hrs to fix

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

          markFileAsShared: function($tr, hasShares, hasLink) {
              var action = $tr.find('.fileactions .action[data-action="Share"]');
              var type = $tr.data('type');
              var icon = action.find('.icon');
              var message;
      Severity: Major
      Found in core/js/share.js - About 2 hrs to fix

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

            share:function(itemType, itemSource, shareType, shareWith, permissions, itemSourceName, expirationDate, callback, errorCallback) {
                // Add a fallback for old share() calls without expirationDate.
                // We should remove this in a later version,
                // after the Apps have been updated.
                if (typeof callback === 'undefined' &&
        Severity: Minor
        Found in core/js/share.js - About 1 hr to fix

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

              loadIcons:function(itemType, fileList, callback) {
                  var path = fileList.dirInfo.path;
                  if (path === '/') {
                      path = '';
                  }
          Severity: Minor
          Found in core/js/share.js - About 1 hr to fix

            Function share has 9 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                share:function(itemType, itemSource, shareType, shareWith, permissions, itemSourceName, expirationDate, callback, errorCallback) {
            Severity: Major
            Found in core/js/share.js - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                                      while (path != last) {
                                          if (path === data.path && !data.link) {
                                              var actions = $fileList.find('.fileactions .action[data-action="Share"]');
                                              var files = $fileList.find('.filename');
                                              var i;
              Severity: Major
              Found in core/js/share.js - About 45 mins to fix

                Function loadItem has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    loadItem:function(itemType, itemSource, callback) {
                        var data = '';
                        var checkReshare = true;
                        var async = !_.isUndefined(callback);
                        if (typeof OC.Share.statuses[itemSource] === 'undefined') {
                Severity: Minor
                Found in core/js/share.js - About 45 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

                Function showDropDown has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    showDropDown:function(itemType, itemSource, appendTo, link, possiblePermissions, filename) {
                Severity: Minor
                Found in core/js/share.js - About 45 mins to fix

                  Function unshare has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      unshare:function(itemType, itemSource, shareType, shareWith, callback) {
                  Severity: Minor
                  Found in core/js/share.js - About 35 mins to fix

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

                        _formatRemoteShare: function(remoteAddress) {
                            var parts = this._REMOTE_OWNER_REGEXP.exec(remoteAddress);
                            if (!parts) {
                                // display as is, most likely to be a simple owner name
                                return escapeHTML(remoteAddress);
                    Severity: Minor
                    Found in core/js/share.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

                    There are no issues that match your filters.

                    Category
                    Status