socketry/socketry

View on GitHub

Showing 12 of 12 total issues

Method connect has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

      def connect(
        remote_addr,
        remote_port,
        local_addr: nil,
        local_port: nil,
Severity: Minor
Found in lib/socketry/ssl/socket.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 change_state has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def change_state(new_state)
        case new_state
        when :connecting
          raise "@socket is unset in #{@state} state" unless @socket
          raise(StateError, "not in the disconnected state (actual: #{@state})") unless @state == :disconnected
Severity: Minor
Found in lib/socketry/tcp/socket.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

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

    class Socket
      include Socketry::Timeout

      attr_reader :state
      attr_reader :addr_fmaily, :remote_addr, :remote_port, :local_addr, :local_port
Severity: Minor
Found in lib/socketry/tcp/socket.rb - About 2 hrs to fix

    File socket.rb has 256 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Socketry
      # Transmission Control Protocol
      module TCP
        # Transmission Control Protocol sockets: Provide stream-like semantics
        class Socket
    Severity: Minor
    Found in lib/socketry/tcp/socket.rb - About 2 hrs to fix

      Method write has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def write(data, timeout: @write_timeout)
              total_written = data.size
              deadline = lifetime + timeout if timeout
      
              begin
      Severity: Minor
      Found in lib/socketry/tcp/socket.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 read has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def read(size, outbuf: "".b, timeout: @write_timeout)
              outbuf.clear
              deadline = lifetime + timeout if timeout
      
              begin
      Severity: Minor
      Found in lib/socketry/tcp/socket.rb - About 55 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 accept has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def accept(tcp_socket, timeout: nil)
              tcp_socket = IO.try_convert(tcp_socket) || raise(TypeError, "couldn't convert #{tcp_socket.class} to IO")
              ssl_socket = @ssl_socket_class.new(tcp_socket, @ssl_context)
      
              begin
      Severity: Minor
      Found in lib/socketry/ssl/socket.rb - About 45 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 resolve has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def resolve(hostname, timeout: nil)
              raise TypeError, "expected String, got #{hostname.class}" unless hostname.is_a?(String)
      
              IPAddr.new(@hosts.getaddress(hostname).sub(/%.*$/, ""))
            rescue ::Resolv::ResolvError
      Severity: Minor
      Found in lib/socketry/resolver/resolv.rb - About 45 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 send has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def send(msg, host: nil, port: nil)
              host = @resolver.resolve(host).to_s if host
              if host || port
                @socket.send(msg, 0, host, port)
              else
      Severity: Minor
      Found in lib/socketry/udp/socket.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

      Method connect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def connect(
              remote_host,
              remote_port,
              local_addr: nil,
              local_port: nil,
      Severity: Minor
      Found in lib/socketry/tcp/socket.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

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

            def initialize(
              ssl_socket_class: OpenSSL::SSL::SSLSocket,
              ssl_context: OpenSSL::SSL::SSLContext.new,
              ssl_params: nil,
              **args
      Severity: Minor
      Found in lib/socketry/ssl/socket.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 connect_nonblock has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def connect_nonblock(
              remote_addr,
              remote_port,
              local_addr: nil,
              local_port: nil
      Severity: Minor
      Found in lib/socketry/tcp/socket.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