celluloid/celluloid-io

View on GitHub

Showing 15 of 17 total issues

Class Stream has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Stream < Socket
      include Enumerable

      # The "sync mode" of the stream
      #
Severity: Minor
Found in lib/celluloid/io/stream.rb - About 3 hrs to fix

    Method read has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

          def read(size=nil, buf=nil)
            if size == 0
              if buf
                buf.clear
                return buf
    Severity: Minor
    Found in lib/celluloid/io/stream.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 create_socket has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

          def create_socket(remote_host, remote_port = nil, local_host = nil, local_port = nil)
            # Is it an IPv4 address?
            begin
              addr = Resolv::IPv4.create(remote_host)
            rescue ArgumentError
    Severity: Minor
    Found in lib/celluloid/io/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

    File stream.rb has 260 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Celluloid
      module IO
        # Base class of all streams in Celluloid::IO
        class Stream < Socket
          include Enumerable
    Severity: Minor
    Found in lib/celluloid/io/stream.rb - About 2 hrs to fix

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

            def initialize(socket)
              if socket.kind_of? ::BasicSocket
                # socket
                fail ArgumentError, "wrong kind of socket (#{socket.class} for UNIXServer)" unless socket.kind_of? ::UNIXServer
                super(socket)
      Severity: Minor
      Found in lib/celluloid/io/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 gets has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def gets(eol=$/, limit=nil)
              idx = @read_buffer.index(eol)
      
              until @eof
                break if idx
      Severity: Minor
      Found in lib/celluloid/io/stream.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 create_socket has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def create_socket(remote_host, remote_port = nil, local_host = nil, local_port = nil)
              # Is it an IPv4 address?
              begin
                addr = Resolv::IPv4.create(remote_host)
              rescue ArgumentError
      Severity: Minor
      Found in lib/celluloid/io/tcp_socket.rb - About 1 hr to fix

        Method do_write has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def do_write(s)
                @write_buffer << s
                @write_buffer.force_encoding(Encoding::BINARY)
        
                if @sync or @write_buffer.size > BLOCK_SIZE or idx = @write_buffer.rindex($/)
        Severity: Minor
        Found in lib/celluloid/io/stream.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 wait has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def wait(io, set)
                # zomg ugly type conversion :(
                unless io.is_a?(::IO) || io.is_a?(OpenSSL::SSL::SSLSocket)
                  if io.respond_to? :to_io
                    io = io.to_io
        Severity: Minor
        Found in lib/celluloid/io/reactor.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 readpartial has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def readpartial(maxlen, buf=nil)
                if maxlen == 0
                  if buf
                    buf.clear
                    return buf
        Severity: Minor
        Found in lib/celluloid/io/stream.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 syswrite has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def syswrite(string)
                length = string.length
                total_written = 0
        
                remaining = string
        Severity: Minor
        Found in lib/celluloid/io/stream.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 resolve has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def resolve(hostname)
                if host = resolve_hostname(hostname)
                  unless ip_address = resolve_host(host)
                    fail Resolv::ResolvError, "invalid entry in hosts file: #{host}"
                  end
        Severity: Minor
        Found in lib/celluloid/io/dns_resolver.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def initialize(*args)
                if args.first.kind_of? ::BasicSocket
                  # socket
                  socket = args.first
                  fail ArgumentError, "wrong number of arguments (#{args.size} for 1)" if args.size != 1
        Severity: Minor
        Found in lib/celluloid/io/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 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def initialize(*args)
                if args.first.kind_of? ::BasicSocket
                  # socket
                  socket = args.first
                  fail ArgumentError, "wrong number of arguments (#{args.size} for 1)" if args.size != 1
        Severity: Minor
        Found in lib/celluloid/io/tcp_server.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 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def initialize(*args)
                if args.first.kind_of? ::BasicSocket
                  # socket
                  socket = args.first
                  fail ArgumentError, "wrong number of arguments (#{args.size} for 1)" if args.size != 1
        Severity: Minor
        Found in lib/celluloid/io/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

        Severity
        Category
        Status
        Source
        Language