NexusSW/nio4r-websocket

View on GitHub
lib/nio/websocket.rb

Summary

Maintainability
A
35 mins
Test Coverage
A
94%

Module has too many lines. [141/100]
Open

  module WebSocket
    class << self
      # Returns the current logger, or creates one at level ERROR if one has not been assigned
      # @return [Logger] the current logger instance
      def logger
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

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

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

      def proxy(remote, options = {})
        server = create_server(options)
        host, port, extra = remote.split(":", 3)
        raise "Specify the remote parameter in 'hostname_or_ip:port' format" if extra || port.to_i == 0 || host.empty?
        Reactor.queue_task do
Severity: Minor
Found in lib/nio/websocket.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.

Assignment Branch Condition size for proxy is too high. [24.88/15]
Open

      def proxy(remote, options = {})
        server = create_server(options)
        host, port, extra = remote.split(":", 3)
        raise "Specify the remote parameter in 'hostname_or_ip:port' format" if extra || port.to_i == 0 || host.empty?
        Reactor.queue_task do
Severity: Minor
Found in lib/nio/websocket.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. [17/10]
Open

      def listen(options = {}, server = nil)
        server ||= create_server(options)
        Reactor.queue_task do
          monitor = Reactor.selector.register(server, :r)
          monitor.value = proc do
Severity: Minor
Found in lib/nio/websocket.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 has too many lines. [16/10]
Open

      def accept_socket(server, options)
        waiting = accept_nonblock server
        if [:r, :w].include? waiting
          logger.warn "Expected to receive new connection, but the server is not quite ready"
          return
Severity: Minor
Found in lib/nio/websocket.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.

Assignment Branch Condition size for listen is too high. [20.64/15]
Open

      def listen(options = {}, server = nil)
        server ||= create_server(options)
        Reactor.queue_task do
          monitor = Reactor.selector.register(server, :r)
          monitor.value = proc do
Severity: Minor
Found in lib/nio/websocket.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. [15/10]
Open

      def try_accept_nonblock(io)
        waiting = accept_nonblock io
        if [:r, :w].include? waiting
          # Only happens on server side ssl negotiation
          Reactor.queue_task do
Severity: Minor
Found in lib/nio/websocket.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.

Assignment Branch Condition size for open_socket is too high. [17.72/15]
Open

      def open_socket(url, options)
        uri = URI(url)
        port = uri.port || (uri.scheme == "wss" ? 443 : 80) # redundant?  test uri.port if port is unspecified but because ws: & wss: aren't default protocols we'll maybe still need this(?)
        logger.debug "Opening Connection to #{uri.hostname} on port #{port}"
        io = TCPSocket.new uri.hostname, port
Severity: Minor
Found in lib/nio/websocket.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 try_accept_nonblock has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def try_accept_nonblock(io)
        waiting = accept_nonblock io
        if [:r, :w].include? waiting
          # Only happens on server side ssl negotiation
          Reactor.queue_task do
Severity: Minor
Found in lib/nio/websocket.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

Line is too long. [98/80]
Open

      # Should raw traffic be logged through the logger?  Disabled by default for security reasons
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Line is too long. [121/80]
Open

      # Create and return a websocket client that communicates either over the given IO object (upgrades the connection),
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

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

require "nio/websocket/adapter/proxy"
Severity: Minor
Found in lib/nio/websocket.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. [105/80]
Open

      # @option options [Hash] :ssl_context Hash from which to create the OpenSSL::SSL::SSLContext object
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Line is too long. [94/80]
Open

      # Returns the current logger, or creates one at level ERROR if one has not been assigned
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Line is too long. [105/80]
Open

      # @option options [Hash] :ssl_context Hash from which to create the OpenSSL::SSL::SSLContext object
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

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

require "openssl"
Severity: Minor
Found in lib/nio/websocket.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. [189/80]
Open

        port = uri.port || (uri.scheme == "wss" ? 443 : 80) # redundant?  test uri.port if port is unspecified but because ws: & wss: aren't default protocols we'll maybe still need this(?)
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Line is too long. [93/80]
Open

          logger.warn "Expected to receive new connection, but the server is not quite ready"
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Line is too long. [93/80]
Open

        logger.info "Proxy Host listening for new connections on port " + options[:port].to_s
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Line is too long. [99/80]
Open

      # @option options [String] :address optional: Specific Address on which to bind the TCPServer
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

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

require "uri"
Severity: Minor
Found in lib/nio/websocket.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. [98/80]
Open

      # @option options [Integer] :port required: Port on which to listen for incoming connections
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

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

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

        logger.info "Proxy Host listening for new connections on port " + options[:port].to_s
Severity: Minor
Found in lib/nio/websocket.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

        logger.info "Resetting reactor subsystem"
Severity: Minor
Found in lib/nio/websocket.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"

Use %i or %I for an array of symbols.
Open

        if [:r, :w].include? waiting
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

This cop can check for array literals made up of symbols that are not using the %i() syntax.

Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

Example: EnforcedStyle: percent (default)

# good
%i[foo bar baz]

# bad
[:foo, :bar, :baz]

Example: EnforcedStyle: brackets

# good
[:foo, :bar, :baz]

# bad
%i[foo bar baz]

Line is too long. [91/80]
Open

              logger.info "Host accepted client connection #{io} on port #{options[:port]}"
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

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

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

        logger = Logger.new(STDERR, progname: "WebSocket", level: Logger::ERROR)
Severity: Minor
Found in lib/nio/websocket.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. [98/80]
Open

      # @option options [Integer] :port required: Port on which to listen for incoming connections
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Line is too long. [96/80]
Open

      # @option options [Hash] :websocket_options Hash to pass to the ::WebSocket::Driver.client
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Line is too long. [100/80]
Open

      # @param server [TCPServer] (DI) TCPServer-like object to use in lieu of starting a new server
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Use port.to_i.zero? instead of port.to_i == 0.
Open

        raise "Specify the remote parameter in 'hostname_or_ip:port' format" if extra || port.to_i == 0 || host.empty?
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

Example: EnforcedStyle: predicate (default)

# bad

foo == 0
0 > foo
bar.baz > 0

# good

foo.zero?
foo.negative?
bar.baz.positive?

Example: EnforcedStyle: comparison

# bad

foo.zero?
foo.negative?
bar.baz.positive?

# good

foo == 0
0 > foo
bar.baz > 0

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

        host, port, extra = remote.split(":", 3)
Severity: Minor
Found in lib/nio/websocket.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. [91/80]
Open

      # @param [IO] io (DI) raw IO object to use in lieu of opening a new connection to url
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Line is too long. [96/80]
Open

      # @option options [Hash] :websocket_options Hash to pass to the ::WebSocket::Driver.server
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Line is too long. [108/80]
Open

        options[:address] ? TCPServer.new(options[:address], options[:port]) : TCPServer.new(options[:port])
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

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

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

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

        logger.info "Host listening for new connections on port " + options[:port].to_s
Severity: Minor
Found in lib/nio/websocket.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. [105/80]
Open

      # @option options [Hash] :ssl_context Hash from which to create the OpenSSL::SSL::SSLContext object
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Line is too long. [83/80]
Open

      # @return server, as passed in, or a new TCPServer if no server was specified
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Line is too long. [83/80]
Open

      # @return server, as passed in, or a new TCPServer if no server was specified
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Line is too long. [112/80]
Open

            accept_socket server, options do |io| # this next block won't run until ssl (if enabled) has started
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Line is too long. [119/80]
Open

        { cert_store: store, verify_mode: OpenSSL::SSL::VERIFY_PEER }.merge(options[:ssl_context] || {}).each do |k, v|
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Missing top-level module documentation comment.
Open

  module WebSocket
Severity: Minor
Found in lib/nio/websocket.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

Line is too long. [118/80]
Open

        raise "Specify the remote parameter in 'hostname_or_ip:port' format" if extra || port.to_i == 0 || host.empty?
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

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

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

Use %i or %I for an array of symbols.
Open

              unless [:r, :w].include? waiting
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

This cop can check for array literals made up of symbols that are not using the %i() syntax.

Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

Example: EnforcedStyle: percent (default)

# good
%i[foo bar baz]

# bad
[:foo, :bar, :baz]

Example: EnforcedStyle: brackets

# good
[:foo, :bar, :baz]

# bad
%i[foo bar baz]

Line is too long. [99/80]
Open

      # @option options [String] :address optional: Specific Address on which to bind the TCPServer
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

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

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

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

        port = uri.port || (uri.scheme == "wss" ? 443 : 80) # redundant?  test uri.port if port is unspecified but because ws: & wss: aren't default protocols we'll maybe still need this(?)
Severity: Minor
Found in lib/nio/websocket.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

          logger.warn "Expected to receive new connection, but the server is not quite ready"
Severity: Minor
Found in lib/nio/websocket.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. [130/80]
Open

      # Establish a proxy host listening on the given port and address, that marshalls all data to/from a new connection on remote
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Line is too long. [85/80]
Open

              logger.info "Proxy connection established between #{srv} and #{client}"
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Line is too long. [87/80]
Open

        logger.info "Host listening for new connections on port " + options[:port].to_s
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Line is too long. [98/80]
Open

      # Should raw traffic be logged through the logger?  Disabled by default for security reasons
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

Line is too long. [84/80]
Open

        logger.debug "Receiving new connection #{waiting} on port #{options[:port]}"
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

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

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

        return io unless uri.scheme == "wss"
Severity: Minor
Found in lib/nio/websocket.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"

Use %i or %I for an array of symbols.
Open

        if [:r, :w].include? waiting
Severity: Minor
Found in lib/nio/websocket.rb by rubocop

This cop can check for array literals made up of symbols that are not using the %i() syntax.

Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

Example: EnforcedStyle: percent (default)

# good
%i[foo bar baz]

# bad
[:foo, :bar, :baz]

Example: EnforcedStyle: brackets

# good
[:foo, :bar, :baz]

# bad
%i[foo bar baz]

There are no issues that match your filters.

Category
Status