ldonnet/rgeo-kml

View on GitHub

Showing 8 of 8 total issues

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

      def _encode_geometry(object_, point_encoder_=nil)  # :nodoc:
        unless point_encoder_
          if object_.factory.property(:has_z_coordinate)
            if object_.factory.property(:has_m_coordinate)
              point_encoder_ = ::Proc.new{ |p_| [p_.x, p_.y, p_.z, p_.m].join(",") }
Severity: Major
Found in lib/rgeo/kml/coder.rb - About 3 hrs to fix

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

          def build
            if multi_geometries?
              @geo_factory.collection(multi_geometries)
            elsif !points.empty?
              return nil unless points.kind_of?(::Array)
    Severity: Minor
    Found in lib/rgeo/kml/multi_geometry_builder.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

    Method build has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def build
            @text.gsub(/\n/, ' ').strip.split(/\s+/).each do |coord|
              x, y, z = coord.split(',')
              if x.nil? || y.nil?
                fail StandardError, 'Coordinates must have at least x and y elements'
    Severity: Minor
    Found in lib/rgeo/kml/coordinates_builder.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 _encode_geometry has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def _encode_geometry(object_, point_encoder_=nil)  # :nodoc:
            unless point_encoder_
              if object_.factory.property(:has_z_coordinate)
                if object_.factory.property(:has_m_coordinate)
                  point_encoder_ = ::Proc.new{ |p_| [p_.x, p_.y, p_.z, p_.m].join(",") }
    Severity: Minor
    Found in lib/rgeo/kml/coder.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

    Avoid deeply nested control flow statements.
    Open

              return nil unless polygons.kind_of?(::Array)
    Severity: Major
    Found in lib/rgeo/kml/multi_geometry_builder.rb - About 45 mins to fix

      Method multi_geometries? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def multi_geometries?
              geometries_counter = 0
              
              geometries_counter += 1 if !points.empty?
              geometries_counter += 1 if !line_strings.empty?
      Severity: Minor
      Found in lib/rgeo/kml/multi_geometry_builder.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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        module Kml
          
          class LinearRingBuilder
            attr_reader :parent, :geo_factory, :linear_ring
            attr_accessor :points, :text
      Severity: Minor
      Found in lib/rgeo/kml/linear_ring_builder.rb and 1 other location - About 20 mins to fix
      lib/rgeo/kml/line_string_builder.rb on lines 2..15

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

      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

        module Kml
          
          class LineStringBuilder
            attr_reader :parent, :geo_factory, :line_string 
            attr_accessor :points, :text
      Severity: Minor
      Found in lib/rgeo/kml/line_string_builder.rb and 1 other location - About 20 mins to fix
      lib/rgeo/kml/linear_ring_builder.rb on lines 2..15

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

      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

      Severity
      Category
      Status
      Source
      Language