NexusSW/nio4r-websocket

View on GitHub
lib/nio/websocket/reactor.rb

Summary

Maintainability
A
1 hr
Test Coverage
B
82%

Assignment Branch Condition size for start is too high. [41.1/15]
Open

        def start
          WebSocket.logger.debug "Starting reactor" unless @reactor
          @reactor ||= Thread.start do
            Thread.current.abort_on_exception = true
            WebSocket.logger.info "Reactor started"
Severity: Minor
Found in lib/nio/websocket/reactor.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [31/10]
Open

        def start
          WebSocket.logger.debug "Starting reactor" unless @reactor
          @reactor ||= Thread.start do
            Thread.current.abort_on_exception = true
            WebSocket.logger.info "Reactor started"
Severity: Minor
Found in lib/nio/websocket/reactor.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method start has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def start
          WebSocket.logger.debug "Starting reactor" unless @reactor
          @reactor ||= Thread.start do
            Thread.current.abort_on_exception = true
            WebSocket.logger.info "Reactor started"
Severity: Minor
Found in lib/nio/websocket/reactor.rb - About 1 hr to fix

    Block has too many lines. [28/25]
    Open

              @reactor ||= Thread.start do
                Thread.current.abort_on_exception = true
                WebSocket.logger.info "Reactor started"
                begin
                  loop do
    Severity: Minor
    Found in lib/nio/websocket/reactor.rb by rubocop

    This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

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

              WebSocket.logger.debug "Starting reactor" unless @reactor
    Severity: Minor
    Found in lib/nio/websocket/reactor.rb 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

                WebSocket.logger.info "Reactor started"
    Severity: Minor
    Found in lib/nio/websocket/reactor.rb 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"

    Line is too long. [148/80]
    Open

                    Thread.pass # give other threads a chance at manipulating our selector (e.g. a new connection on the main thread trying to register)
    Severity: Minor
    Found in lib/nio/websocket/reactor.rb by rubocop

    Missing top-level class documentation comment.
    Open

        class Reactor
    Severity: Minor
    Found in lib/nio/websocket/reactor.rb by rubocop

    This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

    The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

    Example:

    # bad
    class Person
      # ...
    end
    
    # good
    # Description/Explanation of Person class
    class Person
      # ...
    end

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

                  WebSocket.logger.fatal "Error occured in reactor subsystem."
    Severity: Minor
    Found in lib/nio/websocket/reactor.rb 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"

    Line is too long. [109/80]
    Open

                    # If something queues up while this runs, then the selector will also be awoken & won't block
    Severity: Minor
    Found in lib/nio/websocket/reactor.rb by rubocop

    Line is too long. [132/80]
    Open

                        WebSocket.logger.error "Error occured in callback on socket #{monitor.io}.  No longer handling this connection."
    Severity: Minor
    Found in lib/nio/websocket/reactor.rb by rubocop

    Line is too long. [122/80]
    Open

                        monitor.close # protect global loop from being crashed by a misbehaving driver, or a sloppy disconnect
    Severity: Minor
    Found in lib/nio/websocket/reactor.rb by rubocop

    Avoid rescuing without specifying an error class.
    Open

                rescue => e
    Severity: Minor
    Found in lib/nio/websocket/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

    Avoid rescuing without specifying an error class.
    Open

                      rescue => e
    Severity: Minor
    Found in lib/nio/websocket/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

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

    require "nio"
    Severity: Minor
    Found in lib/nio/websocket/reactor.rb 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"

    Line is too long. [82/80]
    Open

                        monitor.value.call(monitor) if monitor.value.respond_to? :call
    Severity: Minor
    Found in lib/nio/websocket/reactor.rb by rubocop

    There are no issues that match your filters.

    Category
    Status