celluloid/celluloid-io

View on GitHub

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

        Similar blocks of code found in 2 locations. 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 and 1 other location - About 45 mins to fix
        lib/celluloid/io/udp_socket.rb on lines 15..23

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

        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 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 and 1 other location - About 45 mins to fix
        lib/celluloid/io/tcp_server.rb on lines 22..30

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

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