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
`` 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: []
Function HttpProvider
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
MODx.HttpProvider = function(config) {
config = config || {};
this.addEvents(
'readsuccess'
,'readfailure'
Function setStaticElementPath
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
,setStaticElementPath: function(type) {
var category = '',
path = '',
name = '',
nameField = 'name',
- Read upRead up
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) {
- Read upRead up
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) {
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({
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) {
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) {
- Read upRead up
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') {
Function setStaticElementPath
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
,setStaticElementPath: function(type) {
var category = '',
path = '',
name = '',
nameField = 'name',
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);
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];
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);
- Read upRead up
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'),
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 {
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) {
- Read upRead up
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;
- Read upRead up
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; }
- Read upRead up
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');
- Read upRead up
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) {
- Read upRead up
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';
- Read upRead up
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({
- Read upRead up
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);
}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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);
}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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);
};
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76