modxcms/revolution

View on GitHub
manager/assets/modext/widgets/modx.treedrop.js

Summary

Maintainability
F
3 days
Test Coverage

Function setup has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

    setup: function() {
        var ddTarget = this.config.target;
        var ddTargetEl = this.config.targetEl;
        var cfg = this.config;

Severity: Minor
Found in manager/assets/modext/widgets/modx.treedrop.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 modx.treedrop.js has 359 lines of code (exceeds 250 allowed). Consider refactoring.
Open

Ext.dd.DragDropMgr.getZIndex = function(element) {
    var body = document.body,
        z,
        zIndex = -1;
    var overTargetEl = element;
Severity: Minor
Found in manager/assets/modext/widgets/modx.treedrop.js - About 4 hrs to fix

    Function setup has 94 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        setup: function() {
            var ddTarget = this.config.target;
            var ddTargetEl = this.config.targetEl;
            var cfg = this.config;
    
    
    Severity: Major
    Found in manager/assets/modext/widgets/modx.treedrop.js - About 3 hrs to fix

      Function InsertElement has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      MODx.window.InsertElement = function(config) {
          config = config || {};
          var resourceCmp = Ext.get('modx-resource-id');
          var resourceId = resourceCmp !== null ? resourceCmp.getValue() : 0;
          Ext.applyIf(config,{
      Severity: Major
      Found in manager/assets/modext/widgets/modx.treedrop.js - About 3 hrs to fix

        Function notifyDrop has 75 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    ,notifyDrop: function(ddSource, e, data) {
                        if (!data.node || !data.node.attributes || !data.node.attributes.type) return false;
                        if (data.node.attributes.type != 'modResource' && data.node.attributes.leaf != true) return false;
                        var v = '';
                        var win = false;
        Severity: Major
        Found in manager/assets/modext/widgets/modx.treedrop.js - About 3 hrs to fix

          Function submit has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              ,submit: function() {
                  var v = '[[';
                  var n = this.config.record.name;
                  var f = this.fp.getForm();
          
          
          Severity: Minor
          Found in manager/assets/modext/widgets/modx.treedrop.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 submit has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              ,submit: function() {
                  var v = '[[';
                  var n = this.config.record.name;
                  var f = this.fp.getForm();
          
          
          Severity: Minor
          Found in manager/assets/modext/widgets/modx.treedrop.js - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                                        if (p) { p.markDirty(); }
            Severity: Major
            Found in manager/assets/modext/widgets/modx.treedrop.js - About 45 mins to fix

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

              MODx.insertForRTE = function(v,cfg) {
                  var fn = cfg.onInsert || false;
                  if (fn) {
                      fn(v,cfg);
                  } else {
              Severity: Minor
              Found in manager/assets/modext/widgets/modx.treedrop.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

              Avoid deeply nested control flow statements.
              Open

                                          if (v == pf.currentid) {
                                              MODx.msg.alert('',_('resource_err_own_parent'));
                                              return false;
                                          }
              Severity: Major
              Found in manager/assets/modext/widgets/modx.treedrop.js - About 45 mins to fix

                Function insertAtCursor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                MODx.insertAtCursor = function(myField, myValue,h) {
                    if (!Ext.isEmpty(h)) {
                        var z = h(myValue);
                        if (z != undefined) {
                            myValue = z;
                Severity: Minor
                Found in manager/assets/modext/widgets/modx.treedrop.js - About 35 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

                Avoid too many return statements within this function.
                Open

                                                return false;
                Severity: Major
                Found in manager/assets/modext/widgets/modx.treedrop.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                  return true;
                  Severity: Major
                  Found in manager/assets/modext/widgets/modx.treedrop.js - About 30 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status