rgeo/activerecord-postgis-adapter

View on GitHub

Showing 9 of 9 total issues

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

        def setup_gis_from_extension
          extension_names.each do |extname|
            if extname == "postgis_topology"
              unless search_path.include?("topology")
                raise ArgumentError, "'topology' must be in schema_search_path for postgis_topology"

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 initialize has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

        def initialize(name, default, sql_type_metadata = nil, null = true,
                       default_function = nil, collation: nil, comment: nil,
                       serial: nil, spatial: nil)
          @sql_type_metadata = sql_type_metadata
          @geographic = !!(sql_type_metadata.sql_type =~ /geography\(/i)
Severity: Minor
Found in lib/active_record/connection_adapters/postgis/spatial_column.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 new_column_definition has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def new_column_definition(name, type, options)
          if (info = PostGISAdapter.spatial_column_options(type.to_sym))
            if (limit = options.delete(:limit))
              options.merge!(limit) if limit.is_a?(::Hash)
            end

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 postgis_connection has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def postgis_connection(config)
        conn_params = config.symbolize_keys

        conn_params.delete_if { |_, v| v.nil? }

Severity: Minor
Found in lib/active_record/connection_adapters/postgis/create_connection.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 initialize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def initialize(name, default, sql_type_metadata = nil, null = true,
                       default_function = nil, collation: nil, comment: nil,
                       serial: nil, spatial: nil)
          @sql_type_metadata = sql_type_metadata
          @geographic = !!(sql_type_metadata.sql_type =~ /geography\(/i)
Severity: Minor
Found in lib/active_record/connection_adapters/postgis/spatial_column.rb - About 1 hr to fix

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

            def create(master_established = false)
              establish_master_connection unless master_established
              extra_configs = { "encoding" => encoding }
              extra_configs["owner"] = username if has_su?
              connection.create_database(configuration["database"], configuration.merge(extra_configs))
    Severity: Minor
    Found in lib/active_record/connection_adapters/postgis/postgis_database_tasks.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            def initialize(name, default, sql_type_metadata = nil, null = true,
                           default_function = nil, collation: nil, comment: nil,
                           serial: nil, spatial: nil)
    Severity: Minor
    Found in lib/active_record/connection_adapters/postgis/spatial_column.rb - About 35 mins to fix

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

              def ensure_installation_configs
                if configuration["setup"] == "default" && !configuration["postgis_extension"]
                  share_dir = `pg_config --sharedir`.strip rescue "/usr/share"
                  control_file = ::File.expand_path("extension/postgis.control", share_dir)
                  if ::File.readable?(control_file)
      Severity: Minor
      Found in lib/active_record/connection_adapters/postgis/postgis_database_tasks.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 parse_sql_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

                def self.parse_sql_type(sql_type)
                  geo_type, srid, has_z, has_m = nil, 0, false, false
      
                  if sql_type =~ /(geography|geometry)\((.*)\)$/i
                    # geometry(Point)
      Severity: Minor
      Found in lib/active_record/connection_adapters/postgis/oid/spatial.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