activerecord/lib/active_record/tasks/database_tasks.rb

Summary

Maintainability
D
2 days
Test Coverage

File database_tasks.rb has 475 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "active_record/database_configurations"

module ActiveRecord
  module Tasks # :nodoc:
    class DatabaseNotSupported < StandardError; end # :nodoc:
Severity: Minor
Found in activerecord/lib/active_record/tasks/database_tasks.rb - About 7 hrs to fix

    Method prepare_all has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

          def prepare_all
            seed = false
    
            each_current_configuration(env) do |db_config|
              with_temporary_pool(db_config) do
    Severity: Minor
    Found in activerecord/lib/active_record/tasks/database_tasks.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 schema_up_to_date? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def schema_up_to_date?(configuration, format = ActiveRecord.schema_format, file = nil)
            db_config = resolve_configuration(configuration)
    
            file ||= schema_dump_path(db_config)
    
    
    Severity: Minor
    Found in activerecord/lib/active_record/tasks/database_tasks.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 check_current_protected_environment! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            def check_current_protected_environment!(db_config)
              with_temporary_pool(db_config) do |pool|
                migration_context = pool.migration_context
                current = migration_context.current_environment
                stored  = migration_context.last_stored_environment
    Severity: Minor
    Found in activerecord/lib/active_record/tasks/database_tasks.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 reconstruct_from_schema has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def reconstruct_from_schema(db_config, format = ActiveRecord.schema_format, file = nil) # :nodoc:
            file ||= schema_dump_path(db_config, format)
    
            check_schema_file(file) if file
    
    
    Severity: Minor
    Found in activerecord/lib/active_record/tasks/database_tasks.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 migrate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def migrate(version = nil)
            scope = ENV["SCOPE"]
            verbose_was, Migration.verbose = Migration.verbose, verbose?
    
            check_target_version
    Severity: Minor
    Found in activerecord/lib/active_record/tasks/database_tasks.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

    Consider simplifying this complex logical expression.
    Open

            if db_config_or_name.is_a?(DatabaseConfigurations::DatabaseConfig)
              schema_cache_path ||
                db_config_or_name.schema_cache_path ||
                schema_cache_env ||
                db_config_or_name.default_schema_cache_path(ActiveRecord::Tasks::DatabaseTasks.db_dir)
    Severity: Major
    Found in activerecord/lib/active_record/tasks/database_tasks.rb - About 40 mins to fix

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

            def dump_schema(db_config, format = ActiveRecord.schema_format) # :nodoc:
              return unless db_config.schema_dump
      
              require "active_record/schema_dumper"
              filename = schema_dump_path(db_config, format)
      Severity: Minor
      Found in activerecord/lib/active_record/tasks/database_tasks.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 for_each has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def for_each(databases) # :nodoc:
              return {} unless defined?(Rails)
      
              database_configs = ActiveRecord::DatabaseConfigurations.new(databases).configs_for(env_name: Rails.env)
      
      
      Severity: Minor
      Found in activerecord/lib/active_record/tasks/database_tasks.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 each_local_configuration has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def each_local_configuration
                configs_for.each do |db_config|
                  next unless db_config.database
      
                  if local_database?(db_config)
      Severity: Minor
      Found in activerecord/lib/active_record/tasks/database_tasks.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 cache_dump_filename has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def cache_dump_filename(db_config_or_name, schema_cache_path: nil)
              if db_config_or_name.is_a?(DatabaseConfigurations::DatabaseConfig)
                schema_cache_path ||
                  db_config_or_name.schema_cache_path ||
                  schema_cache_env ||
      Severity: Minor
      Found in activerecord/lib/active_record/tasks/database_tasks.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

      Method each_current_configuration has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def each_current_configuration(environment, name = nil)
                environments = [environment]
                environments << "test" if environment == "development" && !ENV["SKIP_TEST_DATABASE"] && !ENV["DATABASE_URL"]
      
                environments.each do |env|
      Severity: Minor
      Found in activerecord/lib/active_record/tasks/database_tasks.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

      There are no issues that match your filters.

      Category
      Status