sensu/sensu-redis

View on GitHub
lib/sensu/redis/client.rb

Summary

Maintainability
C
1 day
Test Coverage

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

    class Client < EM::Connection
      include EM::Deferrable
      include Utilities

      attr_accessor :logger, :sentinel, :auto_reconnect, :reconnect_on_error
Severity: Minor
Found in lib/sensu/redis/client.rb - About 3 hrs to fix

    File client.rb has 253 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "sensu/redis/client/constants"
    require "sensu/redis/client/errors"
    require "sensu/redis/utilities"
    require "eventmachine"
    
    
    Severity: Minor
    Found in lib/sensu/redis/client.rb - About 2 hrs to fix

      Method dispatch_response has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

            def dispatch_response(value)
              if @multibulk_count
                @multibulk_values << value
                @multibulk_count -= 1
                if @multibulk_count == 0
      Severity: Minor
      Found in lib/sensu/redis/client.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 parse_response_line has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def parse_response_line(line)
              # Trim off the response type and delimiter (\r\n).
              response = line.slice(1..-3)
              # First character indicates response type.
              case line[0, 1]
      Severity: Minor
      Found in lib/sensu/redis/client.rb - About 1 hr to fix

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

              def authenticate
                if @password
                  send_command(AUTH_COMMAND, @password) do |authenticated|
                    if authenticated
                      yield if block_given?
        Severity: Minor
        Found in lib/sensu/redis/client.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 parse_response_line has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def parse_response_line(line)
                # Trim off the response type and delimiter (\r\n).
                response = line.slice(1..-3)
                # First character indicates response type.
                case line[0, 1]
        Severity: Minor
        Found in lib/sensu/redis/client.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 reconnect! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def reconnect!
                @reconnect_callbacks[:before].call unless @reconnecting
                @reconnecting = true
                EM.add_timer(1) do
                  determine_address do |host, port|
        Severity: Minor
        Found in lib/sensu/redis/client.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 unbind has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def unbind
                @deferred_status = nil
                @pubsub_callbacks = nil
                if @closing
                  @reconnecting = false
        Severity: Minor
        Found in lib/sensu/redis/client.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

        There are no issues that match your filters.

        Category
        Status