eagletmt/switch_point

View on GitHub

Showing 4 of 4 total issues

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

    def assert_valid_config!(config)
      unless config.key?(:readonly) || config.key?(:writable)
        raise ArgumentError.new(':readonly or :writable must be specified')
      end

Severity: Minor
Found in lib/switch_point/config.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 handle_generated_connection has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.handle_generated_connection(conn, parent_method, method_name, *args, &block)
      switch_point = conn.pool.spec.config[:switch_point]
      if switch_point
        proxy = ProxyRepository.find(switch_point[:name])
        case switch_point[:mode]
Severity: Minor
Found in lib/switch_point/connection.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 handle_generated_connection has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def self.handle_generated_connection(conn, parent_method, method_name, *args, &block)
Severity: Minor
Found in lib/switch_point/connection.rb - About 35 mins to fix

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

        def memorize_switch_point(name, mode, pool)
          switch_point = { name: name, mode: mode }
          if pool.equal?(ActiveRecord::Base.connection_pool)
            if mode != :writable
              raise Error.new("ActiveRecord::Base's switch_points must be writable, but #{name} is #{mode}")
    Severity: Minor
    Found in lib/switch_point/proxy.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