marcosortiz/easy_sockets

View on GitHub

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

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            def set_opts(opts)
                @port = opts[:port].to_i
                @port = DEFAULT_PORT if @port <= 0
                
                @logger = opts[:logger] || Logger.new(STDOUT)
    Severity: Major
    Found in lib/easy_sockets/tcp/tcp_server.rb and 1 other location - About 1 hr to fix
    lib/easy_sockets/udp/udp_server.rb on lines 48..61

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 52.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            def set_opts(opts)
                @port = opts[:port].to_i
                @port = DEFAULT_PORT if @port <= 0
                
                @logger = opts[:logger] || Logger.new(STDOUT)
    Severity: Major
    Found in lib/easy_sockets/udp/udp_server.rb and 1 other location - About 1 hr to fix
    lib/easy_sockets/tcp/tcp_server.rb on lines 46..59

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 52.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

                    rescue Errno::EINPROGRESS
                        # Indicates that the connect is in progress. We monitor the
                        # socket for it to become writable, signaling that the connect
                        # is completed.
                        #
    Severity: Minor
    Found in lib/easy_sockets/tcp/tcp_socket.rb and 1 other location - About 25 mins to fix
    lib/easy_sockets/unix/unix_socket.rb on lines 31..43

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 30.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            def start
                return if @started
                @started = true
                @server = UNIXServer.new(@socket_path)
                @logger.info "Listening on #{@socket_path}"
    Severity: Minor
    Found in lib/easy_sockets/unix/unix_server.rb and 1 other location - About 25 mins to fix
    lib/easy_sockets/tcp/tcp_server.rb on lines 26..35

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 30.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            def start
                return if @started
                @started = true
                @server = TCPServer.new(@port)
                @logger.info "Listening on tcp://127.0.0.1:#{@port}"
    Severity: Minor
    Found in lib/easy_sockets/tcp/tcp_server.rb and 1 other location - About 25 mins to fix
    lib/easy_sockets/unix/unix_server.rb on lines 26..35

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 30.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

                    rescue Errno::EINPROGRESS
                        # Indicates that the connect is in progress. We monitor the
                        # socket for it to become writable, signaling that the connect
                        # is completed.
                        #
    Severity: Minor
    Found in lib/easy_sockets/unix/unix_socket.rb and 1 other location - About 25 mins to fix
    lib/easy_sockets/tcp/tcp_socket.rb on lines 33..45

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 30.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

                        msg = read_non_block(connection)
                        next if msg.nil? || msg.empty?
                        sleep @sleep_time
                        write_non_block(connection, msg)
                        if msg.chomp == 'simulate_crash'
    Severity: Minor
    Found in lib/easy_sockets/unix/unix_server.rb and 1 other location - About 15 mins to fix
    lib/easy_sockets/tcp/tcp_server.rb on lines 66..73

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 25.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

                        msg = read_non_block(connection)
                        next if msg.nil? || msg.empty?
                        sleep @sleep_time
                        write_non_block(connection, msg)
                        if msg.chomp == 'simulate_crash'
    Severity: Minor
    Found in lib/easy_sockets/tcp/tcp_server.rb and 1 other location - About 15 mins to fix
    lib/easy_sockets/unix/unix_server.rb on lines 66..73

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 25.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Severity
    Category
    Status
    Source
    Language