rails-on-services/apartment

View on GitHub

Showing 6 of 6 total issues

Class AbstractAdapter has 30 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 connect_to_new has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

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

          def connect_to_new(tenant = nil)
            return reset if tenant.nil?
            raise ActiveRecord::StatementInvalid, "Could not find schema #{tenant}" unless schema_exists?(tenant)
    
            @current = tenant.is_a?(Array) ? tenant.map(&:to_s) : tenant.to_s
    Severity: Minor
    Found in lib/apartment/adapters/jdbc_postgresql_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 connect_to_new has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def connect_to_new(tenant)
            return reset if tenant.nil?
    
            query_cache_enabled = ActiveRecord::Base.connection.query_cache_enabled
    
    
    Severity: Minor
    Found in lib/apartment/adapters/abstract_adapter.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 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