socketry/socketry

View on GitHub
lib/socketry/tcp/socket.rb

Summary

Maintainability
C
1 day
Test Coverage

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

      There are no issues that match your filters.

      Category
      Status