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?)
- Read upRead up
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
- Read upRead up
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
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 =
- Read upRead up
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 = ""
- Read upRead up
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
- Read upRead up
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
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)
- Read upRead up
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
- Read upRead up
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.")
- Read upRead up
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
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
- Read upRead up
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'
- Read upRead up
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?
- Read upRead up
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?
- Read upRead up
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)
Method full_distance
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def full_distance(latitude, longitude, lat_attr, lon_attr, options = {})
Method approx_bearing
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def approx_bearing(latitude, longitude, lat_attr, lon_attr, options = {})
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')
Method approx_distance
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def approx_distance(latitude, longitude, lat_attr, lon_attr, options = {})