nofxx/georuby

View on GitHub
lib/geo_ruby/simple_features/line_string.rb

Summary

Maintainability
C
1 day
Test Coverage

Method bounding_box has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

      def bounding_box
        max_x = max_y = -Float::MAX
        min_x = min_y = Float::MAX
        if with_z
          max_z, min_z = -Float::MAX, Float::MAX
Severity: Minor
Found in lib/geo_ruby/simple_features/line_string.rb - About 4 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

Class LineString has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

    class LineString < Geometry
      # the list of points forming the line string
      attr_reader :points

      def initialize(srid = DEFAULT_SRID, with_z = false, with_m = false)
Severity: Minor
Found in lib/geo_ruby/simple_features/line_string.rb - About 3 hrs to fix

    Method m_range has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def m_range
            if with_m
              max_m, min_m = -Float::MAX, Float::MAX
              each do |point|
                max_m = point.m if point.m.to_f > max_m
    Severity: Minor
    Found in lib/geo_ruby/simple_features/line_string.rb - About 45 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 == has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def ==(other)
            if other.class != self.class ||
               other.length != length
              false
            else
    Severity: Minor
    Found in lib/geo_ruby/simple_features/line_string.rb - About 45 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 6 locations. Consider refactoring.
    Open

          def self.from_coordinates(points, srid = DEFAULT_SRID, z = false, m = false)
            line_string = new(srid, z, m)
            line_string.concat(points.map { |p| Point.from_coordinates(p, srid, z, m) })
            line_string
    Severity: Minor
    Found in lib/geo_ruby/simple_features/line_string.rb and 5 other locations - About 20 mins to fix
    lib/geo_ruby/simple_features/multi_line_string.rb on lines 49..52
    lib/geo_ruby/simple_features/multi_point.rb on lines 45..48
    lib/geo_ruby/simple_features/multi_polygon.rb on lines 48..51
    lib/geo_ruby/simple_features/polygon.rb on lines 158..161
    lib/geo_ruby/simple_features/polygon.rb on lines 165..168

    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

          def euclidian_distance
            total = 0
            @points.each_with_index do |p, i|
              total += p.euclidian_distance(@points[i + 1]) if @points[i + 1]
            end
    Severity: Minor
    Found in lib/geo_ruby/simple_features/line_string.rb and 1 other location - About 15 mins to fix
    lib/geo_ruby/simple_features/line_string.rb on lines 78..83

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

    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 spherical_distance
            total = 0
            @points.each_with_index do |p, i|
              total += p.spherical_distance(@points[i + 1]) if @points[i + 1]
            end
    Severity: Minor
    Found in lib/geo_ruby/simple_features/line_string.rb and 1 other location - About 15 mins to fix
    lib/geo_ruby/simple_features/line_string.rb on lines 86..91

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

    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

    There are no issues that match your filters.

    Category
    Status