scooterw/ffi-ogr

View on GitHub

Showing 8 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 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

          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

          Severity
          Category
          Status
          Source
          Language