rgeo/activerecord-postgis-adapter

View on GitHub

Showing 4 of 4 total issues

Method initialize has a Cognitive Complexity of 12 (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, generated: nil, spatial: nil, identity: 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

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 11 (exceeds 5 allowed). Consider refactoring.
Open

        def new_column_definition(name, type, **options)
          col_type = if type.to_sym == :virtual
            options[:type]
          else
            type

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, generated: nil, spatial: nil, identity: nil)
Severity: Minor
Found in lib/active_record/connection_adapters/postgis/spatial_column.rb - About 35 mins to fix

    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 = nil
                srid = 0
                has_z = false
                has_m = false
    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