Showing 15 of 15 total issues
Class Api
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class Api
# Provide basic HTTP client behaviour.
include HTTParty
# The OSM API version supported by this gem.
Class Element
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Element
include ActiveModel::Validations
include Comparable
# Unique ID
Class Parser
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Rosemary::Parser < HTTParty::Parser
include LibXML::XML::SaxParser::Callbacks
attr_accessor :context, :description, :lang, :collection
Method on_characters
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def on_characters(chars)
case @context.class.name
when 'Rosemary::User'
@context.description = chars if @description
@context.languages << chars if @lang
- 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 on_start_element
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def on_start_element(name, attr_hash) # :nodoc:
case @context.class.name
when 'Rosemary::User'
case name
when 'description' then @description = true
Method method_missing
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def method_missing(method, *args)
methodname = method.to_s
if methodname.slice(-1, 1) == '='
if args.size != 1
raise ArgumentError.new("wrong number of arguments (#{args.size} for 1)")
- 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_xml
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def to_xml(options = {})
xml = options[:builder] ||= Builder::XmlMarkup.new
xml.instruct! unless options[:skip_instruct]
each do |key, value|
# Remove leading and trailing whitespace from tag values
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def <=>(another_relation)
parent_compare = super(another_relation)
# don't bother to compare more stuff if parent comparison failed
return parent_compare unless parent_compare == 0
- 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 38.
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
def <=>(another_way)
parent_compare = super(another_way)
# don't bother to compare more stuff if parent comparison failed
return parent_compare unless parent_compare == 0
- 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 38.
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 to_xml
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def to_xml(options = {})
xml = options[:builder] ||= Builder::XmlMarkup.new
xml.instruct! unless options[:skip_instruct]
xml.osm do
xml.changeset(attributes) do
- 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 on_start_element
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def on_start_element(name, attr_hash) # :nodoc:
case @context.class.name
when 'Rosemary::User'
case name
when 'description' then @description = true
- 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_xml
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def to_xml(options = {})
xml = options[:builder] ||= Builder::XmlMarkup.new
xml.instruct! unless options[:skip_instruct]
xml.osm(:generator => "rosemary v#{Rosemary::VERSION}", :version => Rosemary::Api::API_VERSION) do
xml.way(attributes) do
- 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 add_tags
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def add_tags(new_tags)
case new_tags
when Array # Called with an array
# Call recursively for each entry
new_tags.each do |tag_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 find_element
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def find_element(type, id)
raise ArgumentError.new("type needs to be one of 'node', 'way', and 'relation'") unless type =~ /^(node|way|relation|changeset)$/
return nil if id.nil?
begin
response = get("/#{type}/#{id}")
- 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 _check_id
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _check_id(id)
if id.kind_of?(Integer)
return id
elsif id.kind_of?(String)
raise ArgumentError, "ID must be an integer" unless id =~ /^-?[0-9]+$/
- 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"