lib/volt/server/message_bus/peer_to_peer/peer_connection.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method listen has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

      def listen
        loop do
          begin
            while (message = @message_encoder.receive_message(@socket))
              break if @disconnected
Severity: Minor
Found in lib/volt/server/message_bus/peer_to_peer/peer_connection.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 reconnect! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def reconnect!
        # Stop trying to reconnect if we are disconnected
        return false if @disconnected

        # Don't reconnect on the server instances
Severity: Minor
Found in lib/volt/server/message_bus/peer_to_peer/peer_connection.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 run_worker has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def run_worker
        while (message = @message_queue.pop)
          break if message == :QUIT

          begin
Severity: Minor
Found in lib/volt/server/message_bus/peer_to_peer/peer_connection.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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def initialize(socket, ips, port, message_bus, server=false, peer_server_id=nil)
Severity: Minor
Found in lib/volt/server/message_bus/peer_to_peer/peer_connection.rb - About 45 mins to fix

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

          def initialize(socket, ips, port, message_bus, server=false, peer_server_id=nil)
            @message_bus = message_bus
            @ips = ips
            @port = port
            @server = server
    Severity: Minor
    Found in lib/volt/server/message_bus/peer_to_peer/peer_connection.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

    There are no issues that match your filters.

    Category
    Status