CartoDB/cartodb20

View on GitHub
services/datasources/lib/datasources/url/arcgis.rb

Summary

Maintainability
D
2 days
Test Coverage

File arcgis.rb has 368 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'json'
require 'addressable/uri'
require_relative '../base_direct_stream'
require_relative '../../../../../lib/carto/http/client'

Severity: Minor
Found in services/datasources/lib/datasources/url/arcgis.rb - About 4 hrs to fix

    Class ArcGIS has 28 methods (exceeds 20 allowed). Consider refactoring.
    Open

          class ArcGIS < BaseDirectStream
    
            # Required for all datasources
            DATASOURCE_NAME = 'arcgis'
    
    
    Severity: Minor
    Found in services/datasources/lib/datasources/url/arcgis.rb - About 3 hrs to fix

      Method stream_resource has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

              def stream_resource(id)
                return nil if @ids.empty?
      
                retries = 0
                begin
      Severity: Minor
      Found in services/datasources/lib/datasources/url/arcgis.rb - About 3 hrs 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_by_ids has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def get_by_ids(url, ids, fields)
                raise InvalidInputDataError.new("'ids' empty or invalid") if (ids.nil? || ids.length == 0)
                raise InvalidInputDataError.new("'fields' empty or invalid") if (fields.nil? || fields.length == 0)
      
                oid_field = fields.find { |field| field[:type] == OID_FIELD_TYPE }
      Severity: Major
      Found in services/datasources/lib/datasources/url/arcgis.rb - About 2 hrs to fix

        Method get_by_ids has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

                def get_by_ids(url, ids, fields)
                  raise InvalidInputDataError.new("'ids' empty or invalid") if (ids.nil? || ids.length == 0)
                  raise InvalidInputDataError.new("'fields' empty or invalid") if (fields.nil? || fields.length == 0)
        
                  oid_field = fields.find { |field| field[:type] == OID_FIELD_TYPE }
        Severity: Minor
        Found in services/datasources/lib/datasources/url/arcgis.rb - About 2 hrs 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_subresource_metadata has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def get_subresource_metadata(id, subresource_id)
                  @url = sanitize_id(id, subresource_id)
        
                  response = http_client.get(METADATA_URL % [@url], http_options)
                  validate_response(METADATA_URL % [@url], response)
        Severity: Minor
        Found in services/datasources/lib/datasources/url/arcgis.rb - About 1 hr to fix

          Method stream_resource has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def stream_resource(id)
                    return nil if @ids.empty?
          
                    retries = 0
                    begin
          Severity: Minor
          Found in services/datasources/lib/datasources/url/arcgis.rb - About 1 hr to fix

            Method sanitize_id has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                    def sanitize_id(id, sub_id=nil)
                      # http://<host>/<site>/rest/services/<folder>/<serviceName>/<serviceType>/
                      # <site> is almost always "arcgis" (according to official doc)
                      unless id =~ ARCGIS_API_LIKE_URL_RE
                        raise InvalidInputDataError.new("Url doesn't looks as from ArcGIS server")
            Severity: Minor
            Found in services/datasources/lib/datasources/url/arcgis.rb - About 55 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 block_size has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def block_size(update=true)
                      if update
                        if @current_stream_status && (@block_size < MAX_BLOCK_SIZE)
                          @block_size = [@block_size * BLOCK_FACTOR, MAX_BLOCK_SIZE].min
                        end
            Severity: Minor
            Found in services/datasources/lib/datasources/url/arcgis.rb - About 25 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_layers_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def get_layers_list(url)
                      request_url = LAYERS_URL % [url]
                      response = http_client.get(request_url, http_options)
                      validate_response(request_url, response)
            
            
            Severity: Minor
            Found in services/datasources/lib/datasources/url/arcgis.rb - About 25 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_subresource_metadata has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def get_subresource_metadata(id, subresource_id)
                      @url = sanitize_id(id, subresource_id)
            
                      response = http_client.get(METADATA_URL % [@url], http_options)
                      validate_response(METADATA_URL % [@url], response)
            Severity: Minor
            Found in services/datasources/lib/datasources/url/arcgis.rb - About 25 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

            There are no issues that match your filters.

            Category
            Status