rom-rb/rom-sql

View on GitHub

Showing 27 of 31 total issues

Class Relation has 47 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Relation < ROM::Relation
      # Query API for SQL::Relation
      #
      # @api public
      module Reading
Severity: Minor
Found in lib/rom/sql/relation/reading.rb - About 6 hrs to fix

    Class Attribute has 31 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Attribute < ROM::Attribute
          include AttributeWrapping
          include AttributeAliasing
    
          OPERATORS = %i[>= <= > <].freeze
    Severity: Minor
    Found in lib/rom/sql/attribute.rb - About 3 hrs to fix

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

              def alter_table(diff)
                return if diff.meta?
      
                writer.migration do |connection|
                  connection.alter_table(diff.table_name) do
      Severity: Minor
      Found in lib/rom/sql/migration/runner.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 reading.rb has 278 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require "rom/support/inflector"
      require "rom/sql/join_dsl"
      
      module ROM
        module SQL
      Severity: Minor
      Found in lib/rom/sql/relation/reading.rb - About 2 hrs to fix

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

                def __join__(type, other, join_cond = EMPTY_HASH, opts = EMPTY_HASH, &block)
                  if other.is_a?(Symbol) || other.is_a?(ROM::Relation::Name)
                    if join_cond.equal?(EMPTY_HASH) && !block
                      assoc = associations[other]
                      assoc.join(type, self)
        Severity: Minor
        Found in lib/rom/sql/relation/reading.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 alter_table has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def alter_table(diff)
                  return if diff.meta?
        
                  writer.migration do |connection|
                    connection.alter_table(diff.table_name) do
        Severity: Minor
        Found in lib/rom/sql/migration/runner.rb - About 1 hr to fix

          Method range_read_type has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                  def self.range_read_type(name)
                    SQL::Types.Constructor(Values::Range) do |value|
                      pg_range =
                        if value.is_a?(Sequel::Postgres::PGRange)
                          value
          Severity: Minor
          Found in lib/rom/sql/extensions/postgres/types/range.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 restriction_methods has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                    def self.restriction_methods(schema)
                      mod = Module.new
          
                      methods = schema.indexes.each_with_object([]) do |index, generated|
                        next if index.partial?
          Severity: Minor
          Found in lib/rom/plugins/relation/sql/auto_restrictions.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 call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                  def call(primary_key:, db_type:, type:, allow_null:, **rest)
                    if primary_key
                      map_pk_type(type, db_type, **rest)
                    else
                      mapped_type = map_type(type, db_type, **rest)
          Severity: Minor
          Found in lib/rom/sql/schema/type_builder.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 __join__ has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def __join__(type, other, join_cond = EMPTY_HASH, opts = EMPTY_HASH, &block)
                    if other.is_a?(Symbol) || other.is_a?(ROM::Relation::Name)
                      if join_cond.equal?(EMPTY_HASH) && !block
                        assoc = associations[other]
                        assoc.join(type, self)
          Severity: Minor
          Found in lib/rom/sql/relation/reading.rb - About 1 hr to fix

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

                    def coerce_conditions(conditions)
                      conditions.each_with_object({}) { |(k, v), h|
                        if k.is_a?(Symbol) && schema.canonical.key?(k)
                          type = schema.canonical[k]
                          h[k] = v.is_a?(Array) ? v.map { |e| type[e] } : type[v]
            Severity: Minor
            Found in lib/rom/sql/relation/reading.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 method_missing has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                  def method_missing(meth, *args, &block)
                    if schema.key?(meth)
                      schema[meth]
                    else
                      type = type(meth)
            Severity: Minor
            Found in lib/rom/sql/projection_dsl.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 associate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                      def associate(tuples, curried_parent = nil, assoc:, keys:, parent: curried_parent)
                        result_type = result
            
                        output_tuples =
                          case assoc
            Severity: Minor
            Found in lib/rom/sql/plugin/associates.rb - About 45 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 range has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                    def self.range(name, read_type)
                      Type(name) do
                        type = SQL::Types.Nominal(Values::Range).constructor do |range|
                          format("%s%s,%s%s",
                                 range.exclude_begin? ? :'(' : :'[',
            Severity: Minor
            Found in lib/rom/sql/extensions/postgres/types/range.rb - About 45 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 __join__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    def __join__(type, other, join_cond = EMPTY_HASH, opts = EMPTY_HASH, &block)
            Severity: Minor
            Found in lib/rom/sql/relation/reading.rb - About 35 mins to fix

              Method each_batch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                      def each_batch(size: 1000)
                        pks = schema.primary_key
              
                        if pks.size > 1
                          raise ArgumentError, "Composite primary keys are not supported yet"
              Severity: Minor
              Found in lib/rom/sql/relation/reading.rb - About 35 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 call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                      def call(target: self.target, preload: false)
                        if preload
                          schema = target.schema.qualified
                          relation = target
                        else
              Severity: Minor
              Found in lib/rom/sql/associations/many_to_one.rb - About 35 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 call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                      def call(target: self.target)
                        left = join_assoc.(target: target)
              
                        schema =
                          if left.schema.key?(foreign_key)
              Severity: Minor
              Found in lib/rom/sql/associations/many_to_many.rb - About 35 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 lock_clause has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                      def lock_clause(mode: :update, skip_locked: false, of: nil, wait: nil)
                        stmt = ROW_LOCK_MODES[dataset.db.database_type].fetch(mode).dup
                        stmt << " OF " << Array(of).join(", ") if of
              
                        if skip_locked
              Severity: Minor
              Found in lib/rom/sql/relation/reading.rb - About 35 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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def call(type)
                      return type.meta[:db_type] if type.meta[:db_type]
              
                      meta = type.meta[:read] ? { read: type.meta[:read] } : EMPTY_HASH
              
              
              Severity: Minor
              Found in lib/rom/sql/type_serializer.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