activerecord/lib/active_record/connection_adapters/abstract_adapter.rb

Summary

Maintainability
F
6 days
Test Coverage

Class AbstractAdapter has 143 methods (exceeds 20 allowed). Consider refactoring.
Open

    class AbstractAdapter
      ADAPTER_NAME = "Abstract"
      include ActiveSupport::Callbacks
      define_callbacks :checkout, :checkin

Severity: Major
Found in activerecord/lib/active_record/connection_adapters/abstract_adapter.rb - About 2 days to fix

    File abstract_adapter.rb has 795 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "set"
    require "active_record/connection_adapters/sql_type_metadata"
    require "active_record/connection_adapters/abstract/schema_dumper"
    require "active_record/connection_adapters/abstract/schema_creation"
    require "active_support/concurrency/null_lock"

      Method with_raw_connection has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

              def with_raw_connection(allow_retry: false, materialize_transactions: true)
                @lock.synchronize do
                  connect! if @raw_connection.nil? && reconnect_can_restore_state?
      
                  self.materialize_transactions if materialize_transactions

      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 with_raw_connection has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def with_raw_connection(allow_retry: false, materialize_transactions: true)
                @lock.synchronize do
                  connect! if @raw_connection.nil? && reconnect_can_restore_state?
      
                  self.materialize_transactions if materialize_transactions

        Method initialize has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def initialize(config_or_deprecated_connection, deprecated_logger = nil, deprecated_connection_options = nil, deprecated_config = nil) # :nodoc:
                super()
        
                @raw_connection = nil
                @unconfigured_connection = nil

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

                def reconnect!(restore_transactions: false)
                  retries_available = connection_retries
                  deadline = retry_deadline && Process.clock_gettime(Process::CLOCK_MONOTONIC) + retry_deadline
          
                  @lock.synchronize do

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

                def initialize(config_or_deprecated_connection, deprecated_logger = nil, deprecated_connection_options = nil, deprecated_config = nil) # :nodoc:
                  super()
          
                  @raw_connection = nil
                  @unconfigured_connection = nil
          Severity: Minor
          Found in activerecord/lib/active_record/connection_adapters/abstract_adapter.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 find_cmd_and_exec has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.find_cmd_and_exec(commands, *args) # :doc:
                  commands = Array(commands)
          
                  dirs_on_path = ENV["PATH"].to_s.split(File::PATH_SEPARATOR)
                  unless (ext = RbConfig::CONFIG["EXEEXT"]).empty?
          Severity: Minor
          Found in activerecord/lib/active_record/connection_adapters/abstract_adapter.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 log has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  def log(sql, name = "SQL", binds = [], type_casted_binds = [], statement_name = nil, async: false, &block) # :doc:
          Severity: Minor
          Found in activerecord/lib/active_record/connection_adapters/abstract_adapter.rb - About 45 mins to fix

            There are no issues that match your filters.

            Category
            Status