alexreisner/geocoder

View on GitHub

Showing 70 of 88 total issues

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

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

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

          def parse_json(data)
            if defined?(ActiveSupport::JSON)
              ActiveSupport::JSON.decode(data)
            else
              JSON.parse(data)
    Severity: Minor
    Found in lib/geocoder/lookups/base.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 http_client has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def http_client
            proxy_name = "#{protocol}_proxy"
            if proxy = configuration.send(proxy_name)
              proxy_url = !!(proxy =~ /^#{protocol}/) ? proxy : protocol + '://' + proxy
              begin
    Severity: Minor
    Found in lib/geocoder/lookups/base.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 results has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def results(query)
          return [] unless doc = fetch_data(query)
          if doc['meta'] && doc['meta']['error']
            Geocoder.log(:warn, "2gis Geocoding API error: #{doc['meta']["code"]} (#{doc['meta']['error']["message"]}).")
            return []
    Severity: Minor
    Found in lib/geocoder/lookups/twogis.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 results has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def results(query)
          return [] unless doc = fetch_data(query)
    
          if !doc.is_a?(Array)
            case doc['error']
    Severity: Minor
    Found in lib/geocoder/lookups/location_iq.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 results has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

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

        def results(query)
          return [] unless doc = fetch_data(query)
          if doc['error'].nil?
            [doc]
          # The API returned a 404 response, which indicates no results found
    Severity: Minor
    Found in lib/geocoder/lookups/latlon.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 geocoder_reject_non_ipv4_addresses has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def geocoder_reject_non_ipv4_addresses(ip_addresses)
          ips = []
          for ip in ip_addresses
            begin
              valid_ip = IPAddr.new(ip)
    Severity: Minor
    Found in lib/geocoder/request.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 geocode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def geocode
          do_lookup(false) do |o,rs|
            if r = rs.first
              unless r.latitude.nil? or r.longitude.nil?
                o.__send__  "#{self.class.geocoder_options[:latitude]}=",  r.latitude
    Severity: Minor
    Found in lib/geocoder/stores/active_record.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 results has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def results(query)
          return [] unless (doc = fetch_data(query))
          return [] unless doc['type'] == 'FeatureCollection'
          return [] unless doc['features'] || doc['features'].present?
    
    
    Severity: Minor
    Found in lib/geocoder/lookups/photon.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

    Avoid too many return statements within this method.
    Open

          return []
    Severity: Major
    Found in lib/geocoder/lookups/amap.rb - About 30 mins to fix

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

          def results(query)
            return [] unless doc = fetch_data(query)
            return doc["results"][0]['locations'] if doc['info']['statuscode'] == 0 # A successful geocode call
      
            messages = doc['info']['messages'].join
      Severity: Minor
      Found in lib/geocoder/lookups/mapquest.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 results has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def results(query)
            return [] unless doc = fetch_data(query)
      
            # not all responses include a meta
            if doc['meta']
      Severity: Minor
      Found in lib/geocoder/lookups/pelias.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 raise_error has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def raise_error(error, message = nil)
              exceptions = configuration.always_raise
              if exceptions == :all or exceptions.include?( error.is_a?(Class) ? error : error.class )
                raise error, message
              else
      Severity: Minor
      Found in lib/geocoder/lookups/base.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 geocode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def geocode
            do_lookup(false) do |o,rs|
              if r = rs.first
                unless r.coordinates.nil?
                  o.__send__ "#{self.class.geocoder_options[:coordinates]}=", r.coordinates.reverse
      Severity: Minor
      Found in lib/geocoder/stores/mongo_base.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 bearing_sql has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def bearing_sql(latitude, longitude, options = {})
              if !options.include?(:bearing)
                options[:bearing] = Geocoder.config.distances
              end
              if options[:bearing]
      Severity: Minor
      Found in lib/geocoder/stores/active_record.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 expire has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def expire(url)
            if url == :all
              if store_service.respond_to?(:keys)
                urls.each{ |u| expire(u) }
              else
      Severity: Minor
      Found in lib/geocoder/cache.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 insert_into_table has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def insert_into_table(table, filepath)
            start_time = Time.now
            print "Loading data for table #{table}"
            rows = []
            columns = table_columns(table)
      Severity: Minor
      Found in lib/maxmind_database.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 reverse_geocode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def reverse_geocode
            do_lookup(true) do |o,rs|
              if r = rs.first
                unless r.address.nil?
                  o.__send__ "#{self.class.geocoder_options[:fetched_address]}=", r.address
      Severity: Minor
      Found in lib/geocoder/stores/mongo_base.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 results has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def results(query)
            # don't look up a loopback or private address, just return the stored result
            return [reserved_result(query.text)] if query.internal_ip_address?
            return [] unless doc = fetch_data(query)
            if doc["response"] == "INVALID ACCOUNT"
      Severity: Minor
      Found in lib/geocoder/lookups/ip2location_io.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

      Severity
      Category
      Status
      Source
      Language