alexreisner/geocoder

View on GitHub

Showing 65 of 75 total issues

Class Ipregistry has 72 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Ipregistry < Base

    def initialize(data)
      super

Severity: Major
Found in lib/geocoder/results/ipregistry.rb - About 1 day to fix

    Class Base has 31 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Base
          def initialize
            @cache = nil
          end
    
    
    Severity: Minor
    Found in lib/geocoder/lookups/base.rb - About 3 hrs to fix

      Method run has 90 lines of code (exceeds 25 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: Major
      Found in lib/geocoder/cli.rb - About 3 hrs to fix

        Method to_osgb_36 has 78 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def to_osgb_36
              osgb_fo  = 0.9996012717
              northing0 = -100_000.0
              easting0 = 400_000.0
              phi0 = deg_to_rad(49.0)
        Severity: Major
        Found in lib/easting_northing.rb - About 3 hrs to fix

          Class BanDataGouvFr has 26 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class BanDataGouvFr < Base
          
              #### BASE METHODS ####
          
              def self.response_attributes
          Severity: Minor
          Found in lib/geocoder/results/ban_data_gouv_fr.rb - About 3 hrs to fix

            Class Google has 25 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class Google < Base
            
                def coordinates
                  ['lat', 'lng'].map{ |i| geometry['location'][i] }
                end
            Severity: Minor
            Found in lib/geocoder/results/google.rb - About 2 hrs to fix

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

                  def query_url_google_params(query)
                    params = {
                      :sensor => "false",
                      :language => (query.language || configuration.language)
                    }
              Severity: Minor
              Found in lib/geocoder/lookups/google.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

              Class Yandex has 24 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class Yandex < Base
                  # Yandex result has difficult tree structure,
                  # and presence of some nodes depends on exact search case.
              
                  # Also Yandex lacks documentation about it.
              Severity: Minor
              Found in lib/geocoder/results/yandex.rb - About 2 hrs to fix

                Method near_scope_options has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                      def near_scope_options(latitude, longitude, radius = 20, options = {})
                        if options[:units]
                          options[:units] = options[:units].to_sym
                        end
                        latitude_attribute = options[:latitude] || geocoder_options[:latitude]
                Severity: Minor
                Found in lib/geocoder/stores/active_record.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

                Class Nominatim has 22 methods (exceeds 20 allowed). Consider refactoring.
                Open

                  class Nominatim < Base
                
                    def poi
                      return @data['address'][place_type] if @data['address'].key?(place_type)
                      return nil
                Severity: Minor
                Found in lib/geocoder/results/nominatim.rb - About 2 hrs to fix

                  Method field_names has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def self.field_names
                        {
                          :country => [
                            :country_code,
                            :error
                  Severity: Major
                  Found in lib/geocoder/results/maxmind.rb - About 2 hrs to fix

                    Method search_geocode_ban_fr_params has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def search_geocode_ban_fr_params(query)
                          params = {
                            q: query.sanitized_text
                          }
                          unless (limit = query.options[:limit]).nil? || !limit_param_is_valid?(limit)
                    Severity: Minor
                    Found in lib/geocoder/lookups/ban_data_gouv_fr.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 do_lookup has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def do_lookup(reverse = false)
                            options = self.class.geocoder_options
                            if reverse and options[:reverse_geocode]
                              query = to_coordinates
                            elsif !reverse and options[:geocode]
                    Severity: Minor
                    Found in lib/geocoder/stores/base.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 fetch_raw_data has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def fetch_raw_data(query)
                            key = cache_key(query)
                            if cache and body = cache[key]
                              @cache_hit = true
                            else
                    Severity: Minor
                    Found in lib/geocoder/lookups/base.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 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def results(query, reverse = false)
                          return [] unless doc = fetch_data(query)
                          case [doc['status'], doc['info']]
                          when ['1', 'OK']
                            return doc['regeocodes'] unless doc['regeocodes'].blank?
                    Severity: Minor
                    Found in lib/geocoder/lookups/amap.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 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def results(query)
                          return [] unless doc = fetch_data(query)
                    
                          if doc['statusCode'] == 200
                            return doc['resourceSets'].first['estimatedTotal'] > 0 ? doc['resourceSets'].first['resources'] : []
                    Severity: Minor
                    Found in lib/geocoder/lookups/bing.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 near_scope_options has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def near_scope_options(latitude, longitude, radius = 20, options = {})
                            if options[:units]
                              options[:units] = options[:units].to_sym
                            end
                            latitude_attribute = options[:latitude] || geocoder_options[:latitude]
                    Severity: Minor
                    Found in lib/geocoder/stores/active_record.rb - About 1 hr to fix

                      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 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

                        Severity
                        Category
                        Status
                        Source
                        Language