influitive/apartment

View on GitHub

Showing 6 of 6 total issues

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

    class AbstractAdapter
      include ActiveSupport::Callbacks
      define_callbacks :create, :switch

      attr_writer :default_tenant
Severity: Minor
Found in lib/apartment/adapters/abstract_adapter.rb - About 3 hrs to fix

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

        def extract_tenant_config
          return {} unless @tenant_names
          values = @tenant_names.respond_to?(:call) ? @tenant_names.call : @tenant_names
          unless values.is_a? Hash
            values = values.each_with_object({}) do |tenant, hash|
    Severity: Minor
    Found in lib/apartment.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 connect_to_new has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def connect_to_new(tenant = nil)
            return reset if tenant.nil?
            raise ActiveRecord::StatementInvalid.new("Could not find schema #{tenant}") unless Apartment.connection.schema_exists?(tenant.to_s)
    
            @current = tenant.to_s
    Severity: Minor
    Found in lib/apartment/adapters/postgresql_adapter.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 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def migrate(database)
          Tenant.switch(database) do
            version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
    
            migration_scope_block = -> (migration) { ENV["SCOPE"].blank? || (ENV["SCOPE"] == migration.scope) }
    Severity: Minor
    Found in lib/apartment/migrator.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 connect_to_new has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def connect_to_new(tenant = nil)
            return reset if tenant.nil?
            raise ActiveRecord::StatementInvalid.new("Could not find schema #{tenant}") unless Apartment.connection.all_schemas.include? tenant.to_s
    
            @current = tenant.to_s
    Severity: Minor
    Found in lib/apartment/adapters/jdbc_postgresql_adapter.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def create(tenant)
            run_callbacks :create do
              create_tenant(tenant)
    
              switch(tenant) do
    Severity: Minor
    Found in lib/apartment/adapters/abstract_adapter.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

    Severity
    Category
    Status
    Source
    Language