File mapview.js
has 1200 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* map tab shown in cartodb admin
*/
/**
MapTab
has 71 functions (exceeds 20 allowed). Consider refactoring. Open
cdb.admin.MapTab = cdb.core.View.extend({
events: {
'click .toggle_slides.button': '_toggleSlides',
'click .add_overlay.button': 'killEvent',
Function GrouperLayerMapView
has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring. Open
function GrouperLayerMapView(mapViewClass) {
return {
initialize: function() {
- 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 GrouperLayerMapView
has 147 lines of code (exceeds 25 allowed). Consider refactoring. Open
function GrouperLayerMapView(mapViewClass) {
return {
initialize: function() {
Function _bindDataLayer
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
_bindDataLayer: function(layerView, layer) {
var self = this;
var layerType = layer.get('type');
if (layerType === 'CartoDB' || layerType === 'torque') { // unbind previos stuff
- 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 clearMap
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
clearMap: function() {
clearTimeout(this.autoSaveBoundsTimer);
this.mapView.clean();
Function _addTimeline
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
_addTimeline: function() {
if (!this.mapView) return;
// check if there is some torque layer
if(!this.map.layers.any(function(lyr) { return lyr.get('type') === 'torque' && lyr.get('visible'); })) {
this.timeline && this.timeline.clean();
- 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 _addLegend
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
_addLegend: function(layer) {
var type = layer.get('type');
if (type === 'CartoDB' || type === 'torque') {
- 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 _addInfowindow
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
_addInfowindow: function() {
if(this.infowindow) this.infowindow.clean();
if(this.table && this.mapView) {
this.infowindow = new cdb.admin.MapInfowindow({
model: this.infowindowModel,
Function _bindDataLayer
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
_bindDataLayer: function(layerView, layer) {
var self = this;
var layerType = layer.get('type');
if (layerType === 'CartoDB' || layerType === 'torque') { // unbind previos stuff
Function _showDesktopCanvas
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
_showDesktopCanvas: function(mode) {
var self = this;
this.overlays._hideOverlays("mobile");
Function setupMap
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
setupMap: function() {
this.$('.tipsy').remove();
var self = this;
Function _routeErrors
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
_routeErrors: function(errors) {
var styleRegExp = /style(\d+)/;
var postgresExp = /layer(\d+):/i;
var generalPostgresExp = /PSQL error/i;
var syntaxErrorExp = /syntax error/i;
Function clearMap
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
clearMap: function() {
clearTimeout(this.autoSaveBoundsTimer);
this.mapView.clean();
- 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 checkGeoRef
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
checkGeoRef: function() {
if (this.options && this.table) {
this.georeferenced = this.table.isGeoreferenced();
if (this.noGeoRefDialog) {
this.noGeoRefDialog.hide();
- 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 _showMobileCanvas
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
_showMobileCanvas: function(mode) {
var self = this;
var width = 288;
Function _addTimeline
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
_addTimeline: function() {
if (!this.mapView) return;
// check if there is some torque layer
if(!this.map.layers.any(function(lyr) { return lyr.get('type') === 'torque' && lyr.get('visible'); })) {
this.timeline && this.timeline.clean();
Function _addLayer
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
_addLayer: function(layer, layers, opts) {
opts = opts || {};
// create group layer to acumulate cartodb layers
if (layer.get('type') === 'CartoDB') {
var self = this;
Function _addBasemapDropdown
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
_addBasemapDropdown: function() {
if (!this.basemapDropdown) {
if (this.vis.get("type") !== "table") {
Function bindGeoRefCheck
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
bindGeoRefCheck: function() {
if(!this.table.data().fetched) {
this.table.bind('dataLoaded', function() {
this.checkGeoRef();
if (!this.scratchDialog) {
- 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 _addBasemapDropdown
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
_addBasemapDropdown: function() {
if (!this.basemapDropdown) {
if (this.vis.get("type") !== "table") {
- 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
} else if(generalPostgresExp.exec(err) || syntaxErrorExp.exec(err) || tilerError.exec(err)) {
var error = 'sqlError';
if (webMercatorErrorExp.exec(err)) {
error = 'sqlNoMercator';
err = _t("you should select the_geom_webmercator column");
Avoid deeply nested control flow statements. Open
if (webMercatorErrorExp.exec(err)) {
err = _t("you should select the_geom_webmercator column");
layers[layerIndex].trigger('sqlNoMercator', [err]);
} else {
layers[layerIndex].trigger('sqlParseError', [err]);
Similar blocks of code found in 2 locations. Consider refactoring. Open
var onBackgroundShown = function() {
$map.animate(
{ width: width, marginLeft: -Math.round(width/2) - 1, left: "50%" },
{ easing: "easeOutQuad", duration: 200, complete: onCanvasLandscapeStretched }
- 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 73.
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
var onCanvasLandscapeStretched = function() {
$map.animate(
{ height: height, marginTop: -Math.round(height/2) + 23, top: "50%" },
{ easing: "easeOutQuad", duration: 200, complete: onCanvasPortraitStretched }
- 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 73.
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 4 locations. Consider refactoring. Open
_toggleLegends: function() {
if (this.map.get("legends")) {
this._addLegends();
} else {
this._cleanLegends();
- 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 53.
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
hideDataLayer: function() {
this.mapView.disableInteraction();
this.layerDataView.setOpacity && this.layerDataView.setOpacity(0.5);
},
- 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 51.
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
showDataLayer: function() {
this.mapView.enableInteraction();
this.layerDataView.setOpacity && this.layerDataView.setOpacity(1.0);
},
- 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 51.
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