scooterw/ffi-ogr

View on GitHub

Showing 18 of 18 total issues

File ffi-ogr.rb has 360 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'ffi'
require 'multi_json'

module OGR
  OGR_BASE = File.join(File.dirname(__FILE__), 'ffi-ogr')
Severity: Minor
Found in lib/ffi-ogr.rb - About 4 hrs to fix

    Method copy_with_transform has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def copy_with_transform(driver_name, output_path, spatial_ref=nil, driver_options=nil)
          writer = OGR::Writer.new driver_name
          writer.set_output(output_path)
          out = writer.ptr
    
    
    Severity: Minor
    Found in lib/ffi-ogr/data_source.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

    Method parse_db_config has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_db_config(db_config_file)
          conf =
            if db_config_file.instance_of? String
              YAML.load_file(File.expand_path(db_config_file))
            elsif db_config_file.instance_of? Hash
    Severity: Minor
    Found in lib/ffi-ogr/postgis_reader.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 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Geometry
        attr_accessor :ptr
    
        def initialize(ptr)
          @ptr = FFI::AutoPointer.new(ptr, self.class.method(:release))
    Severity: Minor
    Found in lib/ffi-ogr/geometry.rb - About 2 hrs to fix

      Method copy_with_transform has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def copy_with_transform(driver_name, output_path, spatial_ref=nil, driver_options=nil)
            writer = OGR::Writer.new driver_name
            writer.set_output(output_path)
            out = writer.ptr
      
      
      Severity: Major
      Found in lib/ffi-ogr/data_source.rb - About 2 hrs to fix

        Method cast_geometry has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def cast_geometry(geom_ptr, auto_free=true)
                #options = {auto_free: true}.merge(options)
                raise RuntimeError.new("Geometry pointer is NULL") if geom_ptr.null?
        
                geom_type = FFIOGR.OGR_G_GetGeometryType(geom_ptr)
        Severity: Minor
        Found in lib/ffi-ogr/tools.rb - About 1 hr to fix

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

              def to_format(format, output_path, options={})
                raise RuntimeError.new("Output path not specified.") if output_path.nil?
          
                spatial_ref = options.delete :spatial_ref
          
          
          Severity: Minor
          Found in lib/ffi-ogr/data_source.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 get_driver_by_extension has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_driver_by_extension(extension)
                driver = unless extension == 'kml'
                  DRIVER_TYPES[extension]
                else
                  drivers.include?('LIBKML') ? 'LIBKML' : 'KML'
          Severity: Minor
          Found in lib/ffi-ogr.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 6 locations. Consider refactoring.
          Open

            class MultiPolygon < Geometry
              def self.create(polygons)
                multi_polygon = OGR::Tools.cast_geometry(FFIOGR.OGR_G_CreateGeometry(:multi_polygon))
          
                polygons.each do |polygon|
          Severity: Minor
          Found in lib/ffi-ogr/multi_polygon.rb and 5 other locations - About 15 mins to fix
          lib/ffi-ogr/multi_line_string.rb on lines 2..11
          lib/ffi-ogr/multi_line_string_25d.rb on lines 2..11
          lib/ffi-ogr/multi_point.rb on lines 2..11
          lib/ffi-ogr/multi_point_25d.rb on lines 2..11
          lib/ffi-ogr/multi_polygon_25d.rb on lines 2..11

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

          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 6 locations. Consider refactoring.
          Open

            class MultiPoint25D < Geometry
              def self.create(points)
                multi_point = OGR::Tools.cast_geometry(FFIOGR.OGR_G_CreateGeometry(:multi_point_25d))
          
                points.each do |point|
          Severity: Minor
          Found in lib/ffi-ogr/multi_point_25d.rb and 5 other locations - About 15 mins to fix
          lib/ffi-ogr/multi_line_string.rb on lines 2..11
          lib/ffi-ogr/multi_line_string_25d.rb on lines 2..11
          lib/ffi-ogr/multi_point.rb on lines 2..11
          lib/ffi-ogr/multi_polygon.rb on lines 2..11
          lib/ffi-ogr/multi_polygon_25d.rb on lines 2..11

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

          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 6 locations. Consider refactoring.
          Open

            class MultiLineString < Geometry
              def self.create(line_strings)
                multi_line_string = OGR::Tools.cast_geometry(FFIOGR.OGR_G_CreateGeometry(:multi_line_string))
          
                line_strings.each do |line_string|
          Severity: Minor
          Found in lib/ffi-ogr/multi_line_string.rb and 5 other locations - About 15 mins to fix
          lib/ffi-ogr/multi_line_string_25d.rb on lines 2..11
          lib/ffi-ogr/multi_point.rb on lines 2..11
          lib/ffi-ogr/multi_point_25d.rb on lines 2..11
          lib/ffi-ogr/multi_polygon.rb on lines 2..11
          lib/ffi-ogr/multi_polygon_25d.rb on lines 2..11

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

          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 6 locations. Consider refactoring.
          Open

            class MultiPoint < Geometry
              def self.create(points)
                multi_point = OGR::Tools.cast_geometry(FFIOGR.OGR_G_CreateGeometry(:multi_point))
          
                points.each do |point|
          Severity: Minor
          Found in lib/ffi-ogr/multi_point.rb and 5 other locations - About 15 mins to fix
          lib/ffi-ogr/multi_line_string.rb on lines 2..11
          lib/ffi-ogr/multi_line_string_25d.rb on lines 2..11
          lib/ffi-ogr/multi_point_25d.rb on lines 2..11
          lib/ffi-ogr/multi_polygon.rb on lines 2..11
          lib/ffi-ogr/multi_polygon_25d.rb on lines 2..11

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

          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 6 locations. Consider refactoring.
          Open

            class MultiLineString25D < Geometry
              def self.create(line_strings)
                multi_line_string = OGR::Tools.cast_geometry(FFIOGR.OGR_G_CreateGeometry(:multi_line_string_25d))
          
                line_strings.each do |line_string|
          Severity: Minor
          Found in lib/ffi-ogr/multi_line_string_25d.rb and 5 other locations - About 15 mins to fix
          lib/ffi-ogr/multi_line_string.rb on lines 2..11
          lib/ffi-ogr/multi_point.rb on lines 2..11
          lib/ffi-ogr/multi_point_25d.rb on lines 2..11
          lib/ffi-ogr/multi_polygon.rb on lines 2..11
          lib/ffi-ogr/multi_polygon_25d.rb on lines 2..11

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

          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 6 locations. Consider refactoring.
          Open

            class MultiPolygon25D < Geometry
              def self.create(polygons)
                multi_polygon = OGR::Tools.cast_geometry(FFIOGR.OGR_G_CreateGeometry(:multi_polygon_25d))
          
                polygons.each do |polygon|
          Severity: Minor
          Found in lib/ffi-ogr/multi_polygon_25d.rb and 5 other locations - About 15 mins to fix
          lib/ffi-ogr/multi_line_string.rb on lines 2..11
          lib/ffi-ogr/multi_line_string_25d.rb on lines 2..11
          lib/ffi-ogr/multi_point.rb on lines 2..11
          lib/ffi-ogr/multi_point_25d.rb on lines 2..11
          lib/ffi-ogr/multi_polygon.rb on lines 2..11

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

          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

            class GeometryCollection25D < Geometry
              def self.create(geometries)
                geometry_collection = OGR::Tools.cast_geometry(FFIOGR.OGR_G_CreateGeometry(:geometry_collection_25d))
          
                if geometries.size > 0
          Severity: Minor
          Found in lib/ffi-ogr/geometry_collection_25d.rb and 1 other location - About 15 mins to fix
          lib/ffi-ogr/geometry_collection.rb on lines 2..12

          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

            class Polygon < Geometry
              def self.create(rings)
                polygon = OGR::Tools.cast_geometry(FFIOGR.OGR_G_CreateGeometry(:polygon))
          
                rings.each do |ring|
          Severity: Minor
          Found in lib/ffi-ogr/polygon.rb and 1 other location - About 15 mins to fix
          lib/ffi-ogr/polygon_25d.rb on lines 2..11

          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

            class Polygon25D < Geometry
              def self.create(rings)
                polygon = OGR::Tools.cast_geometry(FFIOGR.OGR_G_CreateGeometry(:polygon_25d))
          
                rings.each do |ring|
          Severity: Minor
          Found in lib/ffi-ogr/polygon_25d.rb and 1 other location - About 15 mins to fix
          lib/ffi-ogr/polygon.rb on lines 2..11

          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

            class GeometryCollection < Geometry
              def self.create(geometries)
                geometry_collection = OGR::Tools.cast_geometry(FFIOGR.OGR_G_CreateGeometry(:geometry_collection))
          
                if geometries.size > 0
          Severity: Minor
          Found in lib/ffi-ogr/geometry_collection.rb and 1 other location - About 15 mins to fix
          lib/ffi-ogr/geometry_collection_25d.rb on lines 2..12

          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

          Severity
          Category
          Status
          Source
          Language