Showing 88 of 88 total issues
Class Ipregistry
has 71 methods (exceeds 20 allowed). Consider refactoring. Open
class Ipregistry < Base
def initialize(data)
super
Class Base
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class Base
def initialize
@cache = nil
end
Class AbstractApi
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class AbstractApi < Base
##
# Geolocation
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
Class BanDataGouvFr
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class BanDataGouvFr < Base
STATE_CODE_MAPPINGS = {
"Guadeloupe" => "01",
"Martinique" => "02",
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)
Class Google
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class Google < Base
def coordinates
['lat', 'lng'].map{ |i| geometry['location'][i] }
end
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)
}
- 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
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.
Class Nominatim
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Nominatim < Base
def poi
return address_data[place_type] if address_data.key?(place_type)
return nil
Class Geoapify
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Geoapify < Base
def address(_format = :full)
properties['formatted']
end
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]
- 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 field_names
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.field_names
{
:country => [
:country_code,
:error
Similar blocks of code found in 2 locations. Consider refactoring. Open
module Geocoder::Result
class PdokNl < Base
def response_attributes
@data
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 76.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
module Geocoder::Result
class NationaalGeoregisterNl < Base
def response_attributes
@data
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 76.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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]
- 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 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)
- 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 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
- 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 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?
- 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 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'] : []
- 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"