sozialhelden/rosemary

View on GitHub

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.
Severity: Minor
Found in lib/rosemary/api.rb - About 3 hrs to fix

    Class Element has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Element
        include ActiveModel::Validations
        include Comparable
    
        # Unique ID
    Severity: Minor
    Found in lib/rosemary/element.rb - About 2 hrs to fix

      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
      
      
      Severity: Minor
      Found in lib/rosemary/parser.rb - About 2 hrs to fix

        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
        Severity: Minor
        Found in lib/rosemary/parser.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 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
        Severity: Minor
        Found in lib/rosemary/parser.rb - About 1 hr to fix

          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)")
          Severity: Minor
          Found in lib/rosemary/element.rb - About 55 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 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
          Severity: Minor
          Found in lib/rosemary/tags.rb - About 55 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

          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
          
          
          Severity: Minor
          Found in lib/rosemary/relation.rb and 1 other location - About 40 mins to fix
          lib/rosemary/way.rb on lines 88..99

          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

          Further Reading

          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
          
          
          Severity: Minor
          Found in lib/rosemary/way.rb and 1 other location - About 40 mins to fix
          lib/rosemary/relation.rb on lines 42..53

          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

          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 do
                  xml.changeset(attributes) do
          Severity: Minor
          Found in lib/rosemary/changeset.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 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
          Severity: Minor
          Found in lib/rosemary/parser.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 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
          Severity: Minor
          Found in lib/rosemary/way.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 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|
          Severity: Minor
          Found in lib/rosemary/element.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 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}")
          Severity: Minor
          Found in lib/rosemary/api.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 _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]+$/
          Severity: Minor
          Found in lib/rosemary/element.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