CartoDB/cartodb20

View on GitHub

Showing 2,455 of 5,951 total issues

Method save_import has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
Open

    def save_import(user, visualization, renamed_tables: {}, full_restore: false)
      old_username = visualization.user.username if visualization.user
      apply_user_limits(user, visualization)
      ActiveRecord::Base.transaction do
        visualization.id = random_uuid unless visualization.id && full_restore
Severity: Minor
Found in app/services/carto/visualizations_export_persistence_service.rb - About 1 day 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

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',
Severity: Major
Found in lib/assets/javascripts/cartodb/table/mapview.js - About 1 day to fix

    Method before_save has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
    Open

      def before_save
        super
        self.quota_in_bytes = self.quota_in_bytes.to_i if !self.quota_in_bytes.nil? && self.quota_in_bytes != self.quota_in_bytes.to_i
        self.updated_at = Time.now
        # Set account_type and default values for organization users
    Severity: Minor
    Found in app/models/user.rb - About 1 day 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

    File layer_panel_view.js has 597 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    
      /**
       *  Layer panel view added in the right menu
       *
       *  - It needs at least layer, visualization and user models.
    Severity: Major
    Found in lib/assets/javascripts/cartodb/table/layer_panel_view.js - About 1 day to fix

      Function GrouperLayerMapView has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
      Open

      function GrouperLayerMapView(mapViewClass) {
      
        return {
      
          initialize: function() {
      Severity: Minor
      Found in lib/assets/javascripts/cartodb/table/mapview.js - About 1 day 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

      File style-converter.js has 582 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      var _ = require('underscore');
      var camshaftReference = require('builder/data/camshaft-reference');
      var Utils = require('builder/helpers/utils');
      var InputQualitativeRamps = require('builder/components/input-color/input-qualitative-ramps/main-view.js');
      
      
      Severity: Major
      Found in lib/assets/javascripts/builder/editor/style/style-converter.js - About 1 day to fix

        File content-view.js has 571 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        var _ = require('underscore');
        var CoreView = require('backbone/core-view');
        var formatter = require('../../formatter');
        var HistogramTitleView = require('./histogram-title-view');
        var HistogramChartView = require('./chart');

          Method notify_permissions_change has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
          Open

            def notify_permissions_change(permissions_changes)
              permissions_changes.each do |c, v|
                # At the moment we just check users permissions
                if c == TYPE_USER
                  v.each do |affected_id, perm|
          Severity: Minor
          Found in app/models/carto/permission.rb - About 1 day 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 createLayerForAnalysisNode has 234 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              createLayerForAnalysisNode: function (nodeId, fromLayerLetter, cfg) {
                var userMaxLayers = userModel.get('limits').max_layers;
                if (layerDefinitionsCollection.getNumberOfDataLayers() >= userMaxLayers) {
                  var err = new Error('max layers reached');
                  err.userMaxLayers = userMaxLayers;
          Severity: Major
          Found in lib/assets/javascripts/builder/data/user-actions.js - About 1 day to fix

            File layer-content-view.js has 553 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            var _ = require('underscore');
            var $ = require('jquery');
            var Backbone = require('backbone');
            var CoreView = require('backbone/core-view');
            var createTextLabelsTabPaneRouted = require('builder/components/tab-pane/create-text-labels-tab-pane-routed');
            Severity: Major
            Found in lib/assets/javascripts/builder/editor/layers/layer-content-view.js - About 1 day to fix

              File tableview.js has 549 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              
              (function() {
              
                  /**
                   * table view shown in admin
              Severity: Major
              Found in lib/assets/javascripts/cartodb/table/tableview.js - About 1 day to fix

                File mobile.js has 547 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                cdb.admin.overlays.MobileLayers = cdb.core.View.extend({
                
                  className: "layer-container",
                
                  template:  cdb.core.Template.compile('<div class="scrollpane"><ul class="layers"></ul></div>'),
                Severity: Major
                Found in lib/assets/javascripts/cartodb/table/overlays/mobile.js - About 1 day to fix

                  File export_user.rb has 540 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require 'pg'
                  require 'redis'
                  require 'yaml'
                  require 'optparse'
                  require 'json'
                  Severity: Major
                  Found in services/user-mover/export_user.rb - About 1 day to fix

                    File visualizations_controller.rb has 537 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    require_relative '../../models/map/presenter'
                    require_relative '../carto/admin/user_table_public_map_adapter'
                    require_relative '../carto/admin/visualization_public_map_adapter'
                    require_relative '../carto/api/visualization_presenter'
                    require_relative '../carto/api/received_notification_presenter'
                    Severity: Major
                    Found in app/controllers/admin/visualizations_controller.rb - About 1 day to fix

                      File api_key.rb has 535 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      require 'securerandom'
                      require './lib/api_key_grants_validator'
                      require_dependency 'carto/errors'
                      require_dependency 'carto/helpers/auth_token_generator'
                      require_dependency 'carto/oauth_provider/scopes/scopes'
                      Severity: Major
                      Found in app/models/carto/api_key.rb - About 1 day to fix

                        Function exports has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
                        Open

                        module.exports = function (CodeMirror) {
                          function Bar (cls, orientation, scroll) {
                            this.orientation = orientation;
                            this.scroll = scroll;
                            this.screen = this.total = this.size = 1;

                        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

                        Class DataImport has 59 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        class DataImport < Sequel::Model
                          include Carto::DataImportConstants
                          include Carto::Configuration
                          include Carto::UUIDHelper
                          include Carto::DataImportCommons
                        Severity: Major
                        Found in app/models/data_import.rb - About 1 day to fix

                          UserModel has 58 functions (exceeds 20 allowed). Consider refactoring.
                          Open

                          const UserModel = Backbone.Model.extend({
                            urlRoot: '/api/v1/users',
                          
                            defaults: {
                              avatar_url: 'http://cartodb.s3.amazonaws.com/static/public_dashboard_default_avatar.png',
                          Severity: Major
                          Found in lib/assets/javascripts/dashboard/data/user-model.js - About 1 day to fix

                            File map_overlays.js has 513 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            //
                            // manages overlays on the map
                            //
                            
                            cdb.admin.MapOverlays = cdb.core.View.extend({
                            Severity: Major
                            Found in lib/assets/javascripts/cartodb/table/overlays/map_overlays.js - About 1 day to fix

                              Function _setSchema has 206 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                _setSchema: function () {
                                  var hasPlaceholder = this.get('type') === GEOREFERENCE_PLACEHOLDER;
                                  BaseAnalysisFormModel.prototype._setSchema.call(this, this._filterSchemaFieldsByType({
                                    type: {
                                      type: 'SelectPlaceholder',
                                Severity
                                Category
                                Status
                                Source
                                Language