File wizard.js
has 445 lines of code (exceeds 250 allowed). Consider refactoring. Open
// form validation
var alwaysTrueValidator = function(form) { return true };
function columnExistsValidatorFor(column_name) {
Function propertiesFromStyle
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
propertiesFromStyle: function(cartocss) {
var parser = new cdb.admin.CartoParser();
var parsed = parser.parse(cartocss);
if (!parsed) return {};
var rules = parsed.getDefaultRules();
- 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 initialize
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
initialize: function() {
// params
this.table = this.get('table');
this.unset('table');
if(!this.table) throw new Error('table is undefined');
WizardProperties
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
cdb.admin.WizardProperties = cdb.core.Model.extend({
initialize: function() {
// params
this.table = this.get('table');
Function linkLayer
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
linkLayer: function(layer) {
var self = this;
/*
* this is disabled because we need to improve propertiesFromStyle method
* in order to not override properties which shouldn't be, see CDB-1566
Function _updateForm
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
_updateForm: function() {
//unbind all forms
for(var k in this.forms) {
var forms = this.forms[k];
for(var f in forms) {
Function propertiesFromStyle
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
propertiesFromStyle: function(cartocss) {
var parser = new cdb.admin.CartoParser();
var parsed = parser.parse(cartocss);
if (!parsed) return {};
var rules = parsed.getDefaultRules();
Function _fillColumns
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
_fillColumns: function(opts) {
var self = this;
// lazy shallow copy
var attrs = JSON.parse(JSON.stringify(this.attributes));
_.each(attrs, function(field) {
Function linkLayer
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
linkLayer: function(layer) {
var self = this;
/*
* this is disabled because we need to improve propertiesFromStyle method
* in order to not override properties which shouldn't be, see CDB-1566
- 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
Avoid deeply nested control flow statements. Open
if (customColumns.length) {
f.value = customColumns[0];
}
Function active
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
active: function(type, props, opts) {
opts = _.defaults(opts || {}, { persist: true });
// if the geometry is undefined the wizard can't be applied
var currentGeom = this.table.geomColumnTypes()[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
Avoid too many return
statements within this function. Open
return {};