bogdanRada/celluloid_pubsub

View on GitHub

Showing 36 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 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

      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

      Avoid comparing a variable with multiple items in a conditional, use Array#include? instead.
      Open

            if url == path || url == '/?'
              reactor.async.work(socket, Actor.current)
            else
              log_debug "Received invalid WebSocket request for: #{url}"
              socket.close
      Severity: Minor
      Found in lib/celluloid_pubsub/web_server.rb by rubocop

      This cop checks against comparing a variable with multiple items, where Array#include? could be used instead to avoid code repetition.

      Example:

      # bad
      a = 'a'
      foo if a == 'a' || a == 'b' || a == 'c'
      
      # good
      a = 'a'
      foo if ['a', 'b', 'c'].include?(a)

      Add an empty line after magic comments.
      Open

      require_relative './helper'
      Severity: Minor
      Found in lib/celluloid_pubsub/base_actor.rb by rubocop

      Checks for a newline after the final magic comment.

      Example:

      # good
      # frozen_string_literal: true
      
      # Some documentation for Person
      class Person
        # Some code
      end
      
      # bad
      # frozen_string_literal: true
      # Some documentation for Person
      class Person
        # Some code
      end

      Add an empty line after magic comments.
      Open

      require_relative './reactor'
      Severity: Minor
      Found in lib/celluloid_pubsub/web_server.rb by rubocop

      Checks for a newline after the final magic comment.

      Example:

      # good
      # frozen_string_literal: true
      
      # Some documentation for Person
      class Person
        # Some code
      end
      
      # bad
      # frozen_string_literal: true
      # Some documentation for Person
      class Person
        # Some code
      end

      Prefer single-quoted strings when you don't need string interpolation or special symbols.
      Open

        gem "celluloid", "0.17.3"
      Severity: Minor
      Found in Appraisals by rubocop

      Checks if uses of quotes match the configured preference.

      Example: EnforcedStyle: single_quotes (default)

      # bad
      "No special symbols"
      "No string interpolation"
      "Just text"
      
      # good
      'No special symbols'
      'No string interpolation'
      'Just text'
      "Wait! What's #{this}!"

      Example: EnforcedStyle: double_quotes

      # bad
      'Just some text'
      'No special chars or interpolation'
      
      # good
      "Just some text"
      "No special chars or interpolation"
      "Every string in #{project} uses double_quotes"

      Add an empty line after magic comments.
      Open

      require 'rubygems'
      Severity: Minor
      Found in lib/celluloid_pubsub.rb by rubocop

      Checks for a newline after the final magic comment.

      Example:

      # good
      # frozen_string_literal: true
      
      # Some documentation for Person
      class Person
        # Some code
      end
      
      # bad
      # frozen_string_literal: true
      # Some documentation for Person
      class Person
        # Some code
      end

      Prefer single-quoted strings when you don't need string interpolation or special symbols.
      Open

        gem "celluloid", "0.18.0.pre"
      Severity: Minor
      Found in Appraisals by rubocop

      Checks if uses of quotes match the configured preference.

      Example: EnforcedStyle: single_quotes (default)

      # bad
      "No special symbols"
      "No string interpolation"
      "Just text"
      
      # good
      'No special symbols'
      'No string interpolation'
      'Just text'
      "Wait! What's #{this}!"

      Example: EnforcedStyle: double_quotes

      # bad
      'Just some text'
      'No special chars or interpolation'
      
      # good
      "Just some text"
      "No special chars or interpolation"
      "Every string in #{project} uses double_quotes"

      Unnecessary spacing detected.
      Open

            data =  json_data.is_a?(Hash) ? json_data.stringify_keys : {}
      Severity: Minor
      Found in lib/celluloid_pubsub/reactor.rb by rubocop

      This cop checks for extra/unnecessary whitespace.

      Example:

      # good if AllowForAlignment is true
      name      = "RuboCop"
      # Some comment and an empty line
      
      website  += "/bbatsov/rubocop" unless cond
      puts        "rubocop"          if     debug
      
      # bad for any configuration
      set_app("RuboCop")
      website  = "https://github.com/bbatsov/rubocop"

      Prefer single-quoted strings when you don't need string interpolation or special symbols.
      Open

      appraise "celluloid-0.16.0" do
      Severity: Minor
      Found in Appraisals by rubocop

      Checks if uses of quotes match the configured preference.

      Example: EnforcedStyle: single_quotes (default)

      # bad
      "No special symbols"
      "No string interpolation"
      "Just text"
      
      # good
      'No special symbols'
      'No string interpolation'
      'Just text'
      "Wait! What's #{this}!"

      Example: EnforcedStyle: double_quotes

      # bad
      'Just some text'
      'No special chars or interpolation'
      
      # good
      "Just some text"
      "No special chars or interpolation"
      "Every string in #{project} uses double_quotes"

      Prefer single-quoted strings when you don't need string interpolation or special symbols.
      Open

        gem "celluloid", "0.16.0"
      Severity: Minor
      Found in Appraisals by rubocop

      Checks if uses of quotes match the configured preference.

      Example: EnforcedStyle: single_quotes (default)

      # bad
      "No special symbols"
      "No string interpolation"
      "Just text"
      
      # good
      'No special symbols'
      'No string interpolation'
      'Just text'
      "Wait! What's #{this}!"

      Example: EnforcedStyle: double_quotes

      # bad
      'Just some text'
      'No special chars or interpolation'
      
      # good
      "Just some text"
      "No special chars or interpolation"
      "Every string in #{project} uses double_quotes"

      Prefer single-quoted strings when you don't need string interpolation or special symbols.
      Open

        gem "celluloid", "0.17.3"
      Severity: Minor
      Found in Appraisals by rubocop

      Checks if uses of quotes match the configured preference.

      Example: EnforcedStyle: single_quotes (default)

      # bad
      "No special symbols"
      "No string interpolation"
      "Just text"
      
      # good
      'No special symbols'
      'No string interpolation'
      'Just text'
      "Wait! What's #{this}!"

      Example: EnforcedStyle: double_quotes

      # bad
      'Just some text'
      'No special chars or interpolation'
      
      # good
      "Just some text"
      "No special chars or interpolation"
      "Every string in #{project} uses double_quotes"

      Add an empty line after magic comments.
      Open

      module CelluloidPubsub

      Checks for a newline after the final magic comment.

      Example:

      # good
      # frozen_string_literal: true
      
      # Some documentation for Person
      class Person
        # Some code
      end
      
      # bad
      # frozen_string_literal: true
      # Some documentation for Person
      class Person
        # Some code
      end

      Avoid rescuing without specifying an error class.
      Open

          rescue => exception
      Severity: Minor
      Found in lib/celluloid_pubsub/reactor.rb by rubocop

      This cop checks for rescuing StandardError. There are two supported styles implicit and explicit. This cop will not register an offense if any error other than StandardError is specified.

      Example: EnforcedStyle: implicit

      # `implicit` will enforce using `rescue` instead of
      # `rescue StandardError`.
      
      # bad
      begin
        foo
      rescue StandardError
        bar
      end
      
      # good
      begin
        foo
      rescue
        bar
      end
      
      # good
      begin
        foo
      rescue OtherError
        bar
      end
      
      # good
      begin
        foo
      rescue StandardError, SecurityError
        bar
      end

      Example: EnforcedStyle: explicit (default)

      # `explicit` will enforce using `rescue StandardError`
      # instead of `rescue`.
      
      # bad
      begin
        foo
      rescue
        bar
      end
      
      # good
      begin
        foo
      rescue StandardError
        bar
      end
      
      # good
      begin
        foo
      rescue OtherError
        bar
      end
      
      # good
      begin
        foo
      rescue StandardError, SecurityError
        bar
      end

      Add an empty line after magic comments.
      Open

      require 'reel/spy'

      Checks for a newline after the final magic comment.

      Example:

      # good
      # frozen_string_literal: true
      
      # Some documentation for Person
      class Person
        # Some code
      end
      
      # bad
      # frozen_string_literal: true
      # Some documentation for Person
      class Person
        # Some code
      end

      Extra blank line detected.
      Open

      
      if CelluloidPubsub::BaseActor.version_less_than_seventeen?
      Severity: Minor
      Found in lib/celluloid_pubsub/base_actor.rb by rubocop

      This cops checks for two or more consecutive blank lines.

      Example:

      # bad - It has two empty lines.
      some_method
      # one empty line
      # two empty lines
      some_method
      
      # good
      some_method
      # one empty line
      some_method

      Avoid using rescue in its modifier form.
      Open

        celluloid_running = Celluloid.running? rescue false
      Severity: Minor
      Found in lib/celluloid_pubsub/base_actor.rb by rubocop

      This cop checks for uses of rescue in its modifier form.

      Example:

      # bad
      some_method rescue handle_error
      
      # good
      begin
        some_method
      rescue
        handle_error
      end

      Prefer single-quoted strings when you don't need string interpolation or special symbols.
      Open

      appraise "celluloid-0.17.3" do
      Severity: Minor
      Found in Appraisals by rubocop

      Checks if uses of quotes match the configured preference.

      Example: EnforcedStyle: single_quotes (default)

      # bad
      "No special symbols"
      "No string interpolation"
      "Just text"
      
      # good
      'No special symbols'
      'No string interpolation'
      'Just text'
      "Wait! What's #{this}!"

      Example: EnforcedStyle: double_quotes

      # bad
      'Just some text'
      'No special chars or interpolation'
      
      # good
      "Just some text"
      "No special chars or interpolation"
      "Every string in #{project} uses double_quotes"
      Severity
      Category
      Status
      Source
      Language