activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb

Summary

Maintainability
D
2 days
Test Coverage

File schema_definitions.rb has 539 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ActiveRecord
  module ConnectionAdapters # :nodoc:
    # Abstract representation of an index definition on a table. Instances of
    # this type are typically created and returned by methods in database
    # adapters. e.g. ActiveRecord::ConnectionAdapters::MySQL::SchemaStatements#indexes

    Class Table has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Table
          include ColumnMethods
    
          attr_reader :name
    
    

      Class TableDefinition has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class TableDefinition
            include ColumnMethods
      
            attr_reader :name, :temporary, :if_not_exists, :options, :as, :comment, :indexes, :foreign_keys, :check_constraints
      
      

        Method defined_for? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def defined_for?(columns = nil, name: nil, unique: nil, valid: nil, include: nil, nulls_not_distinct: nil, **options)
                columns = options[:column] if columns.blank?
                (columns.nil? || Array(self.columns) == Array(columns).map(&:to_s)) &&
                  (name.nil? || self.name == name.to_s) &&
                  (unique.nil? || self.unique == unique) &&

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

              def set_primary_key(table_name, id, primary_key, **options)
                if id && !as
                  pk = primary_key || Base.get_primary_key(table_name.to_s.singularize)
        
                  if id.is_a?(Hash)

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

              def new_column_definition(name, type, **options) # :nodoc:
                if integer_like_primary_key?(type, options)
                  type = integer_like_primary_key_type(type, options)
                end
                type = aliased_types(type.to_s, 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

        There are no issues that match your filters.

        Category
        Status