alexreisner/geocoder

View on GitHub

Showing 70 of 88 total issues

Method results has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def results(query)
      return [] unless doc = fetch_data(query)

      if (doc['error'].nil?)
        if (!query.reverse_geocode?)
Severity: Minor
Found in lib/geocoder/lookups/esri.rb - About 1 hr 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 extract_coordinates has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def extract_coordinates(point)
      case point
      when Array
        if point.size == 2
          lat, lon = point
Severity: Minor
Found in lib/geocoder/calculations.rb - About 1 hr 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 included has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.included(base)
      base.extend ClassMethods
      base.class_eval do

        # scope: geocoded objects
Severity: Minor
Found in lib/geocoder/stores/active_record.rb - About 1 hr to fix

    Method results has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def results(query)
          if configuration[:file]
            geoip_class = RUBY_PLATFORM == "java" ? JGeoIP : GeoIP
            geoip_instance = geoip_class.new(configuration[:file])
            result =
    Severity: Minor
    Found in lib/geocoder/lookups/maxmind_local.rb - About 1 hr 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 select_clause has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def select_clause(columns, distance = nil, bearing = nil, distance_column = 'distance', bearing_column = 'bearing')
            if columns == :id_only
              return full_column_name(primary_key)
            elsif columns == :geo_only
              clause = ""
    Severity: Minor
    Found in lib/geocoder/stores/active_record.rb - About 1 hr 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 included has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.included(base)
          base.extend ClassMethods
          base.class_eval do
    
            # scope: geocoded objects
    Severity: Minor
    Found in lib/geocoder/stores/active_record.rb - About 1 hr 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 to_WGS84 has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def to_WGS84(latlng)
          latitude = latlng[0]
          longitude = latlng[1]
    
          a = 6_377_563.396
    Severity: Minor
    Found in lib/easting_northing.rb - About 1 hr to fix

      Method results has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def results(query)
            # don't look up a loopback or private address, just return the stored result
            return [] if query.internal_ip_address?
            doc = fetch_data(query)
            if doc and doc.is_a?(Hash)
      Severity: Minor
      Found in lib/geocoder/lookups/pointpin.rb - About 1 hr 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 run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.run(args, out = STDOUT)
            show_url  = false
            show_json = false
      
            # remove arguments that are probably coordinates so they are not
      Severity: Minor
      Found in lib/geocoder/cli.rb - About 1 hr 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 results has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def results(query)
            return [] unless doc = fetch_data(query)
            if [400, 403].include? doc['statusCode']
              if doc['statusCode'] == 403 and doc['message'] == 'Invalid key'
                raise_error(Geocoder::InvalidApiKey) || Geocoder.log(:warn, "Invalid API key.")
      Severity: Minor
      Found in lib/geocoder/lookups/yandex.rb - About 1 hr 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

      Consider simplifying this complex logical expression.
      Open

            if !options[:street_address] and (options[:ip_address] or ip_address?)
              name = options[:ip_lookup] || Configuration.ip_lookup || Geocoder::Lookup.ip_services.first
            else
              name = options[:lookup] || Configuration.lookup || Geocoder::Lookup.street_services.first
            end
      Severity: Major
      Found in lib/geocoder/query.rb - About 1 hr to fix

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

              def results(query)
                return [] unless (doc = fetch_data(query))
        
                # The rest of the status codes should be already handled by the default
                # functionality as the API returns correct HTTP response codes in most
        Severity: Minor
        Found in lib/geocoder/lookups/geoapify.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 results has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def results(query)
              return [] unless doc = fetch_data(query)
              return doc["results"] if doc['error'].nil?
              
              if doc['error'] == 'Invalid API key'
        Severity: Minor
        Found in lib/geocoder/lookups/geocodio.rb - About 45 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 results has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def results(query, reverse = false)
              return [] unless doc = fetch_data(query)
              case doc['status']
              when 0
                return [doc[content_key]] unless doc[content_key].blank?
        Severity: Minor
        Found in lib/geocoder/lookups/baidu.rb - About 45 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 make_api_request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def make_api_request(query)
                uri = URI.parse(query_url(query))
                Geocoder.log(:debug, "Geocoder: HTTP request being made for #{uri.to_s}")
                http_client.start(uri.host, uri.port, use_ssl: use_ssl?, open_timeout: configuration.timeout, read_timeout: configuration.timeout) do |client|
                  configure_ssl!(client) if use_ssl?
        Severity: Minor
        Found in lib/geocoder/lookups/base.rb - About 45 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 within_bounding_box has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def within_bounding_box(sw_lat, sw_lng, ne_lat, ne_lng, lat_attr, lon_attr)
        Severity: Minor
        Found in lib/geocoder/sql.rb - About 45 mins to fix

          Method full_distance has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def full_distance(latitude, longitude, lat_attr, lon_attr, options = {})
          Severity: Minor
          Found in lib/geocoder/sql.rb - About 35 mins to fix

            Method approx_bearing has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def approx_bearing(latitude, longitude, lat_attr, lon_attr, options = {})
            Severity: Minor
            Found in lib/geocoder/sql.rb - About 35 mins to fix

              Method select_clause has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                    def select_clause(columns, distance = nil, bearing = nil, distance_column = 'distance', bearing_column = 'bearing')
              Severity: Minor
              Found in lib/geocoder/stores/active_record.rb - About 35 mins to fix

                Method approx_distance has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def approx_distance(latitude, longitude, lat_attr, lon_attr, options = {})
                Severity: Minor
                Found in lib/geocoder/sql.rb - About 35 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language