bogdanRada/celluloid_pubsub

View on GitHub

Showing 4 of 36 total issues

Class Reactor has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Reactor
    include CelluloidPubsub::BaseActor

    # available actions that can be delegated
    AVAILABLE_ACTIONS = %w(unsubscribe_clients unsubscribe subscribe publish unsubscribe_all).freeze
Severity: Minor
Found in lib/celluloid_pubsub/reactor.rb - About 2 hrs to fix

    Class WebServer has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class WebServer < Reel::Server::HTTP
        include CelluloidPubsub::BaseActor
    
        # The hostname on which the webserver runs on by default
        HOST = '0.0.0.0'
    Severity: Minor
    Found in lib/celluloid_pubsub/web_server.rb - About 2 hrs to fix

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

          def run
            loop do
              break if Actor.current.dead? || @websocket.closed? || @server.dead?
              message = try_read_websocket
              handle_websocket_message(message) if message.present?
      Severity: Minor
      Found in lib/celluloid_pubsub/reactor.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

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

          def handle_parsed_websocket_message(json_data)
            data =  json_data.is_a?(Hash) ? json_data.stringify_keys : {}
            if CelluloidPubsub::Reactor::AVAILABLE_ACTIONS.include?(data['client_action'].to_s)
              log_debug "#{self.class} finds actions for  #{json_data}"
              delegate_action(data) if data['client_action'].present?
      Severity: Minor
      Found in lib/celluloid_pubsub/reactor.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