CartoDB/cartodb20

View on GitHub

Showing 5,951 of 5,951 total issues

Method update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    updated_attributes = params[:mobile_app].symbolize_keys.slice(:name, :description, :icon_url, :app_type)
    @mobile_app.name = updated_attributes[:name]
    @mobile_app.icon_url = updated_attributes[:icon_url]
    @mobile_app.description = updated_attributes[:description]
Severity: Minor
Found in app/controllers/carto/admin/mobile_apps_controller.rb - About 35 mins 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

Method from_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def from_url(url_fragments, protocol, domain)
        # To ease testing don't request eactly all URI.split params
        raise UrlFRagmentsError.new("Invalid url_fragments parameter") unless url_fragments.length > 5

        subdomain = url_fragments[2].sub(domain, '.').split('.')[0]
Severity: Minor
Found in app/controllers/carto/api/oembed_controller.rb - About 35 mins 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

Method update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def update
        if params[:cartodb_id].present?
          begin
            resp = @user_table.service.update_row!(params[:cartodb_id], filtered_row)

Severity: Minor
Found in app/controllers/carto/api/records_controller.rb - About 35 mins 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

Method get_types_parameters has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def get_types_parameters
        # INFO: this fits types and type into types, so only types is used for search.
        # types defaults to type if empty.
        # types defaults to derived if type is also empty.
        types = params.fetch(:types, "").split(',')
Severity: Minor
Found in app/controllers/carto/api/visualization_searcher.rb - About 35 mins 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

Method target_user has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def target_user
    if params[:target_user].nil?
      current_viewer
    else
      # just org owners or org admins can manage api keys for other users
Severity: Minor
Found in app/controllers/carto/api/api_keys_controller.rb - About 35 mins 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

Method register_federated_server_query has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def register_federated_server_query(
      federated_server_name:,
      host: nil,
      port: nil,
      dbname: nil,
Severity: Minor
Found in app/services/carto/federated_tables_service.rb - About 35 mins 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

Method insert_redis_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def insert_redis_value(dataset, storage)
      redis_value = JSON.parse($users_metadata.hget(@redis_key, storage) || '[]')
      if dataset[:available_in].include?(storage)
        # Remove a previous dataset if exists
        redis_value = redis_value.reject { |d| d['dataset_id'] == dataset[:dataset_id] }
Severity: Minor
Found in app/services/carto/do_licensing_service.rb - About 35 mins 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

Method initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(user:, connection_id:, project_id:)
      conn = user.connections.find_by(id: connection_id)
      raise Carto::LoadError, 'Missing BigQuery connection' unless conn
      raise Carto::LOadError, 'Invalid BigQuery connection' unless conn.connector == 'bigquery' && conn.complete?

Severity: Minor
Found in app/services/carto/bigquery_tilesets_service.rb - About 35 mins 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

Method token_valid? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def token_valid?
          raise 'invalid_token' unless token

          # Any call would do, we just want to see if communicates or refuses the token
          result = client.search('test search')
Severity: Minor
Found in services/datasources/lib/datasources/url/box.rb - About 35 mins 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

Method viewer_is_owner? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def viewer_is_owner?
        return (@owner_user.id == @viewer_user.id) if (@owner_user && @viewer_user)

        # This can be removed if 'user_name' support is dropped
        layer_opts = @layer.options.nil? ? Hash.new : @layer.options
Severity: Minor
Found in app/controllers/carto/api/layer_presenter.rb - About 35 mins 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

Method merge_dumps_into_stream has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def merge_dumps_into_stream(names_list, stream)
        headers = @json2csv_conversor.generate_headers(@additional_fields[names_list.first]) + "\n"

        streamed_size = headers.length

Severity: Minor
Found in services/datasources/lib/datasources/util/csv_file_dumper.rb - About 35 mins 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

Method export_user_visualizations_to_directory has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def export_user_visualizations_to_directory(user, type, path)
      root_dir = Pathname.new(path)
      user.visualizations.where(type: type).each do |visualization|
        next if visualization.canonical? && should_skip_canonical_viz_export(visualization)
        next if !visualization.remote? && visualization.map.nil?
Severity: Minor
Found in app/services/carto/user_metadata_export_service.rb - About 35 mins 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

Method store_subscriber_if_opened has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def store_subscriber_if_opened(input_fields='[]', subscribers)
          contents = ::JSON.parse(input_fields)
          contents.each { |subject, actions|
            unless actions.length == 0
              actions.each { |action|
Severity: Minor
Found in services/datasources/lib/datasources/url/mailchimp.rb - About 35 mins 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

Method fetch_headers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def fetch_headers(url)
          if url =~ URL_REGEXP
            response = http_client.head(url, http_options)

            raise DataDownloadTimeoutError.new(DATASOURCE_NAME) if response.timed_out?
Severity: Minor
Found in services/datasources/lib/datasources/url/public_url.rb - About 35 mins 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

Method overview_tables has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def overview_tables(table_name)
      overviews_data = @database.fetch(%{SELECT * FROM cartodb.CDB_Overviews('#{table_name}'::REGCLASS)})
      if overviews_data
        overviews_data.map { |row| row[:overview_table] }
      else
Severity: Minor
Found in app/services/carto/overviews_service.rb - About 35 mins 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

Method get_date_range has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_date_range(service, metric, date_from, date_to)
      check_valid_data(service, metric)

      ret = {}
      month_values = {}
Severity: Minor
Found in services/dataservices-metrics/lib/service_usage_metrics.rb - About 35 mins 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

Method create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def create
        group = Carto::Group.new_instance(@database_name, @name, @database_role)
        if group.save
          render json: group.to_json
        else
Severity: Minor
Found in app/controllers/carto/api/database_groups_controller.rb - About 35 mins 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

Method rollback_import_from_directory has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def rollback_import_from_directory(path)
      user = user_from_file(path)
      return unless user

      user = ::User[user.id]
Severity: Minor
Found in app/services/carto/user_metadata_export_service.rb - About 35 mins 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

Method is_country_column? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def is_country_column?(column)
        return false unless is_text_type? column
        entropy = metric_entropy(column, country_name_normalizer)
        if entropy < minimum_entropy
          false
Severity: Minor
Found in services/importer/lib/importer/content_guesser.rb - About 35 mins 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

Method file_too_big? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def file_too_big?
        (exit_code == 256 && command_output =~ /calloc failed/i) ||
          (exit_code == 256 && command_output =~ /out of memory/i) ||
          (exit_code == 134) ||
          (exit_code == 139) ||
Severity: Minor
Found in services/importer/lib/importer/ogr2ogr.rb - About 35 mins 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

Severity
Category
Status
Source
Language