marcosortiz/easy_sockets

View on GitHub

Showing 11 of 19 total issues

Method on_connect has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

        def on_connect
            @socket = Socket.new(:INET, :STREAM)
            begin
                # Initiate a nonblocking connection
                remote_addr = Socket.pack_sockaddr_in(@port, @host)
Severity: Minor
Found in lib/easy_sockets/tcp/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 on_connect has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

        def on_connect
            @socket = Socket.new(:UNIX, :STREAM)
            begin
                # Initiate a nonblocking connection
                remote_addr = Socket.pack_sockaddr_un(@socket_path)
Severity: Minor
Found in lib/easy_sockets/unix/unix_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 handle has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def handle(connection)
            loop do
                shutdown if @stop_requested
                begin
                    msg = read_non_block(connection)
Severity: Minor
Found in lib/easy_sockets/tcp/tcp_server.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 handle has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def handle(connection)
            loop do
                shutdown if @stop_requested
                begin
                    msg = read_non_block(connection)
Severity: Minor
Found in lib/easy_sockets/unix/unix_server.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 send_msg has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def send_msg(msg, read_response=true)
            msg_to_send = msg.dup
            msg_to_send << @separator unless @separator.nil? || msg.end_with?(@separator)

            # This is an idempotent operation
Severity: Minor
Found in lib/easy_sockets/basic_socket.rb - About 1 hr to fix

    Method send_msg has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def send_msg(msg, read_response=true)
                msg_to_send = msg.dup
                msg_to_send << @separator unless @separator.nil? || msg.end_with?(@separator)
    
                # This is an idempotent operation
    Severity: Minor
    Found in lib/easy_sockets/basic_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 udp_read_non_block has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def udp_read_non_block(connection)
                total_msg = ''
                addr = nil
                begin
                    msg, addr = connection.recvfrom_nonblock(CHUNK_SIZE)
    Severity: Minor
    Found in lib/easy_sockets/utils/server_utils.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 handle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def handle(connection)
                loop do
                    shutdown if @stop_requested
                    begin
                        msg, addr = udp_read_non_block(connection)
    Severity: Minor
    Found in lib/easy_sockets/udp/udp_server.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 read_non_block has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def read_non_block(connection)
                msg = ''
                begin
                    msg << connection.read_nonblock(EasySockets::CHUNK_SIZE)
                    while !msg.end_with?(@separator) do
    Severity: Minor
    Found in lib/easy_sockets/utils/server_utils.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 write_non_block has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def write_non_block(connection, msg)
                return 0 unless msg && msg.is_a?(String)
                total_bytes = 0
                begin
                    loop do
    Severity: Minor
    Found in lib/easy_sockets/utils/server_utils.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 receive_non_block has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def receive_non_block
                resp = ''
                begin
                    resp << @socket.read_nonblock(CHUNK_SIZE)
                    while @separator && !resp.end_with?(@separator) do
    Severity: Minor
    Found in lib/easy_sockets/basic_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

    Severity
    Category
    Status
    Source
    Language