activerecord/lib/active_record/migration/compatibility.rb

Summary

Maintainability
C
1 day
Test Coverage

File compatibility.rb has 384 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ActiveRecord
  class Migration
    module Compatibility # :nodoc: all
      def self.find(version)
        version = version.to_s
Severity: Minor
Found in activerecord/lib/active_record/migration/compatibility.rb - About 5 hrs to fix

    Method index_name_for_remove has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

              def index_name_for_remove(table_name, column_name, options)
                index_name = connection.index_name(table_name, column_name || options)
    
                unless connection.index_name_exists?(table_name, index_name)
                  if options.key?(:name)
    Severity: Minor
    Found in activerecord/lib/active_record/migration/compatibility.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 create_table has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def create_table(table_name, **options)
              if connection.adapter_name == "PostgreSQL"
                if options[:id] == :uuid && !options.key?(:default)
                  options[:default] = "uuid_generate_v4()"
                end
    Severity: Minor
    Found in activerecord/lib/active_record/migration/compatibility.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 change_column has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def change_column(table_name, column_name, type, **options)
              if connection.adapter_name == "PostgreSQL"
                super(table_name, column_name, type, **options.except(:default, :null, :comment))
                connection.change_column_default(table_name, column_name, options[:default]) if options.key?(:default)
                connection.change_column_null(table_name, column_name, options[:null], options[:default]) if options.key?(:null)
    Severity: Minor
    Found in activerecord/lib/active_record/migration/compatibility.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 legacy_index_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

                def legacy_index_name(table_name, options)
                  if Hash === options
                    if options[:column]
                      "index_#{table_name}_on_#{Array(options[:column]) * '_and_'}"
                    elsif options[:name]
    Severity: Minor
    Found in activerecord/lib/active_record/migration/compatibility.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

    There are no issues that match your filters.

    Category
    Status