thiagopradi/octopus

View on GitHub
lib/octopus/proxy_config.rb

Summary

Maintainability
C
1 day
Test Coverage

Class ProxyConfig has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

  class ProxyConfig
    CURRENT_MODEL_KEY = 'octopus.current_model'.freeze
    CURRENT_SHARD_KEY = 'octopus.current_shard'.freeze
    CURRENT_GROUP_KEY = 'octopus.current_group'.freeze
    CURRENT_SLAVE_GROUP_KEY = 'octopus.current_slave_group'.freeze
Severity: Minor
Found in lib/octopus/proxy_config.rb - About 3 hrs to fix

    Method current_shard= has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def current_shard=(shard_symbol)
          if shard_symbol.is_a?(Array)
            self.current_slave_group = nil
            shard_symbol.each { |symbol| fail "Nonexistent Shard Name: #{symbol}" if shards[symbol].nil? }
          elsif shard_symbol.is_a?(Hash)
    Severity: Minor
    Found in lib/octopus/proxy_config.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 initialize_shards has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize_shards(config)
          @original_config = config
    
          self.shards = HashWithIndifferentAccess.new
          self.shards_slave_groups = HashWithIndifferentAccess.new
    Severity: Minor
    Found in lib/octopus/proxy_config.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 initialize_shards has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def initialize_shards(config)
          @original_config = config
    
          self.shards = HashWithIndifferentAccess.new
          self.shards_slave_groups = HashWithIndifferentAccess.new
    Severity: Major
    Found in lib/octopus/proxy_config.rb - About 2 hrs to fix

      Method current_shard= has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def current_shard=(shard_symbol)
            if shard_symbol.is_a?(Array)
              self.current_slave_group = nil
              shard_symbol.each { |symbol| fail "Nonexistent Shard Name: #{symbol}" if shards[symbol].nil? }
            elsif shard_symbol.is_a?(Hash)
      Severity: Minor
      Found in lib/octopus/proxy_config.rb - About 1 hr to fix

        There are no issues that match your filters.

        Category
        Status