crashtech/torque-postgresql

View on GitHub

Showing 52 of 57 total issues

Class Period has 59 methods (exceeds 20 allowed). Consider refactoring.
Open

        class Period
          DIRECT_ACCESS_REGEX = /_?%s_?/
          SUPPORTED_TYPES = %i[daterange tsrange tstzrange].freeze
          CURRENT_GETTERS = {
            daterange: 'Date.today',
Severity: Major
Found in lib/torque/postgresql/attributes/builder/period.rb - About 1 day to fix

    Class BelongsToManyAssociation has 29 methods (exceeds 20 allowed). Consider refactoring.
    Open

          class BelongsToManyAssociation < ::ActiveRecord::Associations::CollectionAssociation
            include ::ActiveRecord::Associations::ForeignAssociation
    
            ## CUSTOM
            def ids_reader
    Severity: Minor
    Found in lib/torque/postgresql/associations/belongs_to_many_association.rb - About 3 hrs to fix

      Method find_model has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

                def find_model(max_name, table_name, scope = Object)
                  pieces = max_name.is_a?(::Array) ? max_name : max_name.split(/(::)/)
                  ns_places = (1..(max_name.size - 1)).step(2).to_a
      
                  # Generate all possible combinations
      Severity: Minor
      Found in lib/torque/postgresql/schema_cache/inheritance.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 prepare_sub_query has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

                def prepare_sub_query(base, settings)
                  @union_all = settings.union_all if @union_all.nil?
                  @sub_query ||= settings.sub_query
                  @depth ||= settings.depth
                  @path ||= settings.path
      Severity: Minor
      Found in lib/torque/postgresql/auxiliary_statement/recursive.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 dump_tables has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

                def dump_tables(stream)
                  inherited_tables = @connection.inherited_tables
                  sorted_tables = (@connection.tables - @connection.views).sort_by do |table_name|
                    table_name.split(/(?:public)?\./).reverse
                  end
      Severity: Minor
      Found in lib/torque/postgresql/adapter/schema_dumper.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 dangerous? has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

                  def dangerous?(method_name, class_method = false)
                    if class_method
                      if klass.dangerous_class_method?(method_name)
                        raise Interrupt, method_name.to_s
                      end
      Severity: Minor
      Found in lib/torque/postgresql/attributes/builder/enum.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 build has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                def build
                  @klass_module = Module.new
                  @instance_module = Module.new
      
                  value_args      = ['value']
      Severity: Minor
      Found in lib/torque/postgresql/attributes/builder/period.rb - About 1 hr to fix

        Method prepare has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

                def prepare(base, settings)
                  requires = Array.wrap(settings.requires).flatten.compact
                  @dependencies = ensure_dependencies(requires, base).flatten.compact
        
                  @join_type ||= settings.join_type || :inner
        Severity: Minor
        Found in lib/torque/postgresql/auxiliary_statement.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 expose_columns has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

                def expose_columns(base, query_table = nil)
                  # Add the columns necessary for the join
                  list = @join_sources.each_with_object(@select) do |join, hash|
                    join.right.expr.children.each do |item|
                      hash[item.left.name] = nil if item.left.relation.eql?(table)
        Severity: Minor
        Found in lib/torque/postgresql/auxiliary_statement.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 touch_record has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

                  def self.touch_record(o, changes, foreign_key, name, touch, touch_method) # :nodoc:
                    old_foreign_ids = changes[foreign_key] && changes[foreign_key].first
        
                    if old_foreign_ids.present?
                      association = o.association(name)
        Severity: Minor
        Found in lib/torque/postgresql/associations/builder/belongs_to_many.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 lookup_model has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

                def lookup_model(table_name, scoped_class = '', source_to_model:)
                  scoped_class = scoped_class.name if scoped_class.is_a?(Class)
                  return source_to_model[table_name] if source_to_model.key?(table_name)
        
                  # Get all the possible scopes
        Severity: Minor
        Found in lib/torque/postgresql/schema_cache/inheritance.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 handle_dependency has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def handle_dependency
                  case options[:dependent]
                  when :restrict_with_exception
                    raise ActiveRecord::DeleteRestrictionError.new(reflection.name) unless empty?
        
        
        Severity: Minor
        Found in lib/torque/postgresql/associations/belongs_to_many_association.rb - About 1 hr to fix

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

                    def extra_columns(base, columns, sub_columns)
                      return if @query.is_a?(String) || @sub_query.is_a?(String)
          
                      # Add the connect attribute to the query
                      if defined?(@connect)
          Severity: Minor
          Found in lib/torque/postgresql/auxiliary_statement/recursive.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 resolve_column has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                def resolve_column(list, base = false)
                  base = resolve_base_table(base)
          
                  Array.wrap(list).map do |item|
                    case item
          Severity: Minor
          Found in lib/torque/postgresql/relation.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 build_query has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                    def build_query(base)
                      # Expose columns and get the list of the ones for select
                      columns = expose_columns(base, @query.try(:arel_table))
                      sub_columns = columns.dup
                      type = @union_all.present? ? 'all' : ''
          Severity: Minor
          Found in lib/torque/postgresql/auxiliary_statement/recursive.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 add_enum_values has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                  def add_enum_values(name, values, options = {})
                    before = options.fetch(:before, false)
                    after  = options.fetch(:after,  false)
          
                    before = enum_values(name).first if options.key? :prepend
          Severity: Minor
          Found in lib/torque/postgresql/adapter/schema_statements.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 prepare_sub_query has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                    def prepare_sub_query(base, settings)
                      @union_all = settings.union_all if @union_all.nil?
                      @sub_query ||= settings.sub_query
                      @depth ||= settings.depth
                      @path ||= settings.path
          Severity: Minor
          Found in lib/torque/postgresql/auxiliary_statement/recursive.rb - About 1 hr to fix

            Method dump_tables has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                      def dump_tables(stream)
                        inherited_tables = @connection.inherited_tables
                        sorted_tables = (@connection.tables - @connection.views).sort_by do |table_name|
                          table_name.split(/(?:public)?\./).reverse
                        end
            Severity: Minor
            Found in lib/torque/postgresql/adapter/schema_dumper.rb - About 1 hr to fix

              Method handle_dependency has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                      def handle_dependency
                        case options[:dependent]
                        when :restrict_with_exception
                          raise ActiveRecord::DeleteRestrictionError.new(reflection.name) unless empty?
              
              
              Severity: Minor
              Found in lib/torque/postgresql/associations/belongs_to_many_association.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 power has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                        def power(*values)
                          values.flatten.map do |item|
                            item = item.to_i if item.is_a?(Enum)
                            item = values.index(item) unless item.is_a?(Numeric)
              
              
              Severity: Minor
              Found in lib/torque/postgresql/attributes/enum_set.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

              Severity
              Category
              Status
              Source
              Language