nofxx/georuby

View on GitHub

Showing 57 of 91 total issues

File shp.rb has 599 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'date'
require 'fileutils' unless defined?(FileUtils)

module GeoRuby
  module Shp4r
Severity: Major
Found in lib/geo_ruby/shp4r/shp.rb - About 1 day to fix

    Method parse_geometry has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_geometry(georss, with_tags)
          georss.strip!
          # check for W3CGeo first
          if georss =~ /<[^:>]*:lat\s*>([^<]*)</
            # if valid, it is W3CGeo
    Severity: Minor
    Found in lib/geo_ruby/georss.rb - About 1 day 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 get_record has 150 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def get_record(index)
            return nil if record_count <= index || index < 0
            dbf_record = @dbf.record(index)
            @shx.seek(100 + 8 * index) # 100 is the header length
            offset, length = @shx.read(8).unpack('N2')
    Severity: Major
    Found in lib/geo_ruby/shp4r/shp.rb - About 6 hrs to fix

      Class Point has 41 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Point < Geometry
            DEG2RAD = 0.0174532925199433
            HALFPI  = 1.5707963267948966
            attr_accessor :x, :y, :z, :m
            attr_reader :r, :t # radium and theta
      Severity: Minor
      Found in lib/geo_ruby/simple_features/point.rb - About 5 hrs to fix

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

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

        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

        Method parse_geometry has 111 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def parse_geometry(georss, with_tags)
              georss.strip!
              # check for W3CGeo first
              if georss =~ /<[^:>]*:lat\s*>([^<]*)</
                # if valid, it is W3CGeo
        Severity: Major
        Found in lib/geo_ruby/georss.rb - About 4 hrs to fix

          Method commit_add has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

                def commit_add(index)
                  max_x, min_x, max_y, min_y, max_z, min_z, max_m, min_m = @shp.xmax, @shp.xmin, @shp.ymax, @shp.ymin, @shp.zmax, @shp.zmin, @shp.mmax, @shp.mmin
                  @added.each do |record|
                    @dbf_io << ['20'].pack('H2')
                    @dbf.fields.each do |field|
          Severity: Minor
          Found in lib/geo_ruby/shp4r/shp.rb - About 3 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

          File point.rb has 310 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'geo_ruby/simple_features/geometry'
          
          module GeoRuby
            module SimpleFeatures
              # Represents a point. It is in 3D if the Z coordinate is not +nil+.
          Severity: Minor
          Found in lib/geo_ruby/simple_features/point.rb - About 3 hrs to fix

            Method parse has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

                def parse(kml)
                  @factory.reset
                  @with_z = false
                  @parser = REXML::Parsers::PullParser.new(kml)
                  while @parser.has_next?
            Severity: Minor
            Found in lib/geo_ruby/kml.rb - About 3 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 parse_coordinates has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  def parse_coordinates(buffer)
                    if buffer =~ /<coordinates>(.+)<\/coordinates>/m
                      Regexp.last_match[1].gsub(/\n/, ' ').strip.split(/\s+/).each do |coord|
                        x, y, z = coord.split(',')
                        if x.nil? || y.nil?
              Severity: Minor
              Found in lib/geo_ruby/kml.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 parse_coords has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                    def parse_coords
                      coords = []
                      x = @tokenizer_structure.get_next_token
                      y = @tokenizer_structure.get_next_token
              
              
              Severity: Minor
              Found in lib/geo_ruby/ewk/ewkt_parser.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

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

                  class Geometry
                    # SRID of the geometry
                    attr_reader :srid # writer defined below
                    # Flag indicating if the z ordinate of the geometry is meaningful
                    attr_accessor :with_z
              Severity: Minor
              Found in lib/geo_ruby/simple_features/geometry.rb - About 2 hrs to fix

                Method build_shp_geometry has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def build_shp_geometry(geometry)
                        m_range = nil
                        answer =
                        case @shp.shp_type
                        when ShpType::POINT
                Severity: Major
                Found in lib/geo_ruby/shp4r/shp.rb - About 2 hrs to fix

                  Method human_representation has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def human_representation(options = {}, g = { x: x, y: y })
                          g.map do |k, v|
                            deg = v.to_i.abs
                            min = (60 * (v.abs - deg)).to_i
                            labs = (v * 1_000_000).abs / 1_000_000
                  Severity: Minor
                  Found in lib/geo_ruby/simple_features/point.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 parse_file has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def parse_file(with_z, with_m)
                          data = @gpx.read
                          @file_mode = data =~ /trkpt/ ? '//trkpt' : (data =~ /wpt/ ? '//wpt' : '//rtept')
                          Nokogiri.HTML(data).search(@file_mode).each do |tp|
                            z = z.inner_text.to_f if with_z && z = tp.at('ele')
                  Severity: Minor
                  Found in lib/geo_ruby/gpx.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

                  File ewkt_parser.rb has 252 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require 'strscan'
                  
                  module GeoRuby
                    module SimpleFeatures
                      # Raised when an error in the EWKT string is detected
                  Severity: Minor
                  Found in lib/geo_ruby/ewk/ewkt_parser.rb - About 2 hrs to fix

                    Method parse_geometry has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def parse_geometry(srid_allowed)
                            token = @tokenizer_structure.get_next_token
                            if token == 'SRID'
                              # SRID present
                              fail EWKTFormatError.new('SRID not allowed at this position') unless srid_allowed
                    Severity: Minor
                    Found in lib/geo_ruby/ewk/ewkt_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 ellipsoidal_distance has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def ellipsoidal_distance(point, a = 6_378_137.0, b = 6_356_752.3142)
                            f = (a - b) / a
                            l = (point.lon - lon) * DEG2RAD
                    
                            u1 = Math.atan((1 - f) * Math.tan(lat * DEG2RAD))
                    Severity: Minor
                    Found in lib/geo_ruby/simple_features/point.rb - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language