CartoDB/cartodb20

View on GitHub
lib/assets/javascripts/builder/deep-insights-integration/layers-integration.js

Summary

Maintainability
D
1 day
Test Coverage

File layers-integration.js has 300 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var _ = require('underscore');
var Backbone = require('backbone');
var LegendManager = require('./legend-manager');
var linkLayerInfowindow = require('./link-layer-infowindow');
var linkLayerTooltip = require('./link-layer-tooltip');

    Function _onLayerDefinitionChanged has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      _onLayerDefinitionChanged: function (layerDefinitionModel, changedAttributes) {
        var attrs = layerDefinitionModel.changedAttributes();
        var attrsNames = _.keys(attrs);
    
        // Base and labels layers are synced in a separate method

    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 _onBaseLayerChanged has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _onBaseLayerChanged: function () {
        var baseLayerDefinition = this._layerDefinitionsCollection.getBaseLayer();
        var newBaseLayerAttrs = baseLayerDefinition.changedAttributes();
    
        var newBaseLayerType = baseLayerDefinition.get('type');

      Function _setLayerError has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _setLayerError: function (layerDefinitionModel, cdbError) {
          var notification = Notifier.getNotification(layerDefinitionModel.id);
          var mainErrorMessage = layerDefinitionModel.getName() + ': ' + (cdbError && cdbError.message);
      
          if (!cdbError) {

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

          _onBaseLayerChanged: function () {
            var baseLayerDefinition = this._layerDefinitionsCollection.getBaseLayer();
            var newBaseLayerAttrs = baseLayerDefinition.changedAttributes();
        
            var newBaseLayerType = baseLayerDefinition.get('type');

        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 _onLayerDefinitionChanged has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _onLayerDefinitionChanged: function (layerDefinitionModel, changedAttributes) {
            var attrs = layerDefinitionModel.changedAttributes();
            var attrsNames = _.keys(attrs);
        
            // Base and labels layers are synced in a separate method

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

            track: function (options) {
              checkAndBuildOpts(options, REQUIRED_OPTS, this);
          
              this._visMap = this._diDashboardHelpers.visMap();
          
          

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

              _setLayerError: function (layerDefinitionModel, cdbError) {
                var notification = Notifier.getNotification(layerDefinitionModel.id);
                var mainErrorMessage = layerDefinitionModel.getName() + ': ' + (cdbError && cdbError.message);
            
                if (!cdbError) {

            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

            There are no issues that match your filters.

            Category
            Status