modxcms/revolution

View on GitHub
manager/assets/modext/core/modx.js

Summary

Maintainability
F
6 days
Test Coverage

File modx.js has 957 lines of code (exceeds 250 allowed). Consider refactoring.
Open

Ext.namespace('MODx');
Ext.apply(Ext,{
    isFirebug: (window.console && window.console.firebug)
});
/* work around IE9 createContextualFragment bug
Severity: Major
Found in manager/assets/modext/core/modx.js - About 2 days to fix

    `` has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

    Ext.extend(MODx,Ext.Component,{
        config: {}
        ,util:{},window:{},panel:{},tree:{},form:{},grid:{},combo:{},toolbar:{},page:{},msg:{}
        ,expandHelp: true
        ,defaultState: []
    Severity: Minor
    Found in manager/assets/modext/core/modx.js - About 4 hrs to fix

      Function HttpProvider has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      MODx.HttpProvider = function(config) {
          config = config || {};
          this.addEvents(
              'readsuccess'
              ,'readfailure'
      Severity: Major
      Found in manager/assets/modext/core/modx.js - About 2 hrs to fix

        Function setStaticElementPath has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            ,setStaticElementPath: function(type) {
                var category   = '',
                    path       = '',
                    name       = '',
                    nameField  = 'name',
        Severity: Minor
        Found in manager/assets/modext/core/modx.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 request has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            request: function(config) {
                Ext.apply(config,{
                    success: function(r,o) {
                        r = Ext.decode(r.responseText);
                        if (!r) {
        Severity: Minor
        Found in manager/assets/modext/core/modx.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 request has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            request: function(config) {
                Ext.apply(config,{
                    success: function(r,o) {
                        r = Ext.decode(r.responseText);
                        if (!r) {
        Severity: Minor
        Found in manager/assets/modext/core/modx.js - About 1 hr to fix

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

              ,clearCache: function() {
                  if (!this.fireEvent('beforeClearCache')) { return false; }
          
                  var topic = '/clearcache/';
                  this.console = MODx.load({
          Severity: Minor
          Found in manager/assets/modext/core/modx.js - About 1 hr to fix

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

                ,getStaticElementsPath: function(name, category, type) {
                    var path = MODx.config.static_elements_basepath,
                        ext  = '';
            
                    if (category.length > 0) {
            Severity: Minor
            Found in manager/assets/modext/core/modx.js - About 1 hr to fix

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

                  ,renameLabel: function(ct,flds,vals) {
                      var cto;
                      if (ct == 'modx-panel-resource' && flds.indexOf('modx-resource-content') != -1) {
                          cto = Ext.getCmp('modx-resource-content');
                          if (cto) {
              Severity: Minor
              Found in manager/assets/modext/core/modx.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 loadHelpPane has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  ,loadHelpPane: function(b) {
                      var url = MODx.helpUrl || MODx.config.help_url || '';
                      if (!url || !url.length) { return false; }
              
                      if (url.substring(0, 4) !== 'http') {
              Severity: Minor
              Found in manager/assets/modext/core/modx.js - About 1 hr to fix

                Function setStaticElementPath has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    ,setStaticElementPath: function(type) {
                        var category   = '',
                            path       = '',
                            name       = '',
                            nameField  = 'name',
                Severity: Minor
                Found in manager/assets/modext/core/modx.js - About 1 hr to fix

                  Function onAjaxException has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      ,onAjaxException: function(conn,r,opt,e) {
                          try {
                              r = Ext.decode(r.responseText);
                          } catch (e) {
                              var text, matched = r.responseText.match(/<body[^>]*>([\w|\W]*)<\/body>/im);
                  Severity: Minor
                  Found in manager/assets/modext/core/modx.js - About 1 hr to fix

                    Function confirm has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        confirm: function(config) {
                            this.purgeListeners();
                            if (config.listeners) {
                                for (var i in config.listeners) {
                                  var l = config.listeners[i];
                    Severity: Minor
                    Found in manager/assets/modext/core/modx.js - About 1 hr to fix

                      Function onAjaxException has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          ,onAjaxException: function(conn,r,opt,e) {
                              try {
                                  r = Ext.decode(r.responseText);
                              } catch (e) {
                                  var text, matched = r.responseText.match(/<body[^>]*>([\w|\W]*)<\/body>/im);
                      Severity: Minor
                      Found in manager/assets/modext/core/modx.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 refreshURIs has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          ,refreshURIs: function() {
                              var topic = '/refreshuris/';
                              MODx.msg.status({
                                  title: _('please_wait'),
                                  message: _('refreshuris_desc'),
                      Severity: Minor
                      Found in manager/assets/modext/core/modx.js - About 1 hr to fix

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

                            ,onWriteSuccess: function(r,o) {
                                r = Ext.decode(r.responseText);
                                if (true !== r.success) {
                                    this.dirty = true;
                                } else {
                        Severity: Minor
                        Found in manager/assets/modext/core/modx.js - About 1 hr to fix

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

                              ,hideRegion: function(ct,tab) {
                                  var tp = Ext.getCmp(ct);
                                  if (tp) {
                                      var tabObj = tp.getItem(tab);
                                      if (tabObj) {
                          Severity: Minor
                          Found in manager/assets/modext/core/modx.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

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

                              ,_getNextActiveTab: function(tp,tab) {
                                  if (MODx.hiddenTabs.indexOf(tab) != -1) {
                                      var id;
                                      for (var i=0;i<tp.items.items.length;i++) {
                                           id = tp.items.items[i].id;
                          Severity: Minor
                          Found in manager/assets/modext/core/modx.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

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

                              ,moveTV: function(tvs,tab) {
                                  if (!Ext.isArray(tvs)) { tvs = [tvs]; }
                                  var tvp = Ext.getCmp('modx-panel-resource-tv');
                                  if (!tvp) { return; }
                          
                          
                          Severity: Minor
                          Found in manager/assets/modext/core/modx.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

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

                              ,status: function(opt) {
                                  if (!MODx.stMsgCt) {
                                      MODx.stMsgCt = Ext.DomHelper.insertFirst(document.body, {id:'modx-status-message-ct'}, true);
                                  }
                                  MODx.stMsgCt.alignTo(document, 't-t');
                          Severity: Minor
                          Found in manager/assets/modext/core/modx.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

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

                              ,getStaticElementsPath: function(name, category, type) {
                                  var path = MODx.config.static_elements_basepath,
                                      ext  = '';
                          
                                  if (category.length > 0) {
                          Severity: Minor
                          Found in manager/assets/modext/core/modx.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

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

                              ,highlightField: function(f) {
                                  if (f.id !== undefined && f.id !== 'forEach' && f.id !== '') {
                                      var fld = Ext.get(f.id);
                                      if (fld && fld.dom) {
                                          fld.dom.style.border = '1px solid red';
                          Severity: Minor
                          Found in manager/assets/modext/core/modx.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

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

                              ,clearCache: function() {
                                  if (!this.fireEvent('beforeClearCache')) { return false; }
                          
                                  var topic = '/clearcache/';
                                  this.console = MODx.load({
                          Severity: Minor
                          Found in manager/assets/modext/core/modx.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

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

                                          if (config.listeners.failure && config.listeners.failure.fn) {
                                              this._runCallback(config.listeners.failure, [r]);
                                              MODx.form.Handler.errorJSON(r);
                                          }
                          Severity: Major
                          Found in manager/assets/modext/core/modx.js and 1 other location - About 1 hr to fix
                          manager/assets/modext/core/modx.js on lines 630..633

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

                          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

                                          } else if (config.listeners.failure && config.listeners.failure.fn) {
                                              this._runCallback(config.listeners.failure, [r]);
                                              MODx.form.Handler.errorJSON(r);
                                          }
                          Severity: Major
                          Found in manager/assets/modext/core/modx.js and 1 other location - About 1 hr to fix
                          manager/assets/modext/core/modx.js on lines 642..645

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

                          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

                          MODx.form.Handler = function(config) {
                              config = config || {};
                              MODx.form.Handler.superclass.constructor.call(this,config);
                          };
                          Severity: Major
                          Found in manager/assets/modext/core/modx.js and 1 other location - About 1 hr to fix
                          manager/assets/modext/widgets/system/modx.panel.system.settings.js on lines 76..79

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

                          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