eventmachine/eventmachine

View on GitHub

Showing 147 of 147 total issues

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

  def self.klass_from_handler(klass = Connection, handler = nil, *args)
    klass = if handler and handler.is_a?(Class)
      raise ArgumentError, "must provide module or subclass of #{klass.name}" unless klass >= handler
      handler
    elsif handler
Severity: Minor
Found in lib/eventmachine.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_request has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def send_request args
        args[:verb] ||= args[:method] # Support :method as an alternative to :verb.
        args[:verb] ||= :get # IS THIS A GOOD IDEA, to default to GET if nothing was specified?

        verb = args[:verb].to_s.upcase
Severity: Minor
Found in lib/em/protocols/httpclient.rb - About 1 hr to fix

    Method hosts has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.hosts
            return @hosts if @hosts
    
            @hosts = {}
            IO.readlines(HOSTS_FILE).each do |line|
    Severity: Minor
    Found in lib/em/resolver.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 isAcceptable has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        void isAcceptable (SelectionKey k) {
            ServerSocketChannel ss = (ServerSocketChannel) k.channel();
            SocketChannel sn;
            long b;
    
    
    Severity: Minor
    Found in java/src/com/rubyeventmachine/EmReactor.java - 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 run has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.run blk=nil, tail=nil, &block
        # Obsoleted the use_threads mechanism.
        # 25Nov06: Added the begin/ensure block. We need to be sure that release_machine
        # gets called even if an exception gets thrown within any of the user code
        # that the event loop runs. The best way to see this is to run a unit
    Severity: Minor
    Found in lib/eventmachine.rb - About 1 hr to fix

      Method set_tls_parms has 13 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def set_tls_parms signature, priv_key_path, priv_key, priv_key_pass, cert_chain_path, cert, verify_peer, fail_if_no_peer_cert, sni_hostname, cipher_list, ecdh_curve, dhparam, protocols_bitmask
      Severity: Major
      Found in lib/em/pure_ruby.rb - About 1 hr to fix

        Method dir_config_wrapper has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def dir_config_wrapper(pretty_name, name, idefault=nil, ldefault=nil)
          inc, lib = dir_config(name, idefault, ldefault)
          if inc && lib
            unless idefault && ldefault
              abort "-----\nCannot find #{pretty_name} include path #{inc}\n-----" unless inc && inc.split(File::PATH_SEPARATOR).any? { |dir| File.directory?(dir) }
        Severity: Minor
        Found in ext/extconf.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 process_rcpt_to has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def process_rcpt_to rcpt
                unless @state.include?(:mail_from)
                  send_data "503 MAIL is required before RCPT\r\n"
                else
                  succeeded = proc {
        Severity: Minor
        Found in lib/em/protocols/smtpserver.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 each has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def each(foreach=nil, after=nil, &blk)
              raise ArgumentError, 'proc or block required for iteration' unless foreach ||= blk
              raise RuntimeError, 'cannot iterate over an iterator more than once' if @started or @ended
        
              @started = true
        Severity: Minor
        Found in lib/em/iterator.rb - About 1 hr to fix

          Method process_header has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def process_header
                    unless @header_lines.first =~ HttpResponseRE
                      @conn.close_connection
                      @internal_error = :bad_request
                    end
          Severity: Minor
          Found in lib/em/protocols/httpclient2.rb - About 1 hr to fix

            Method receive_data_response has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                  def receive_data_response
                    return invoke_error unless @range == 3
            
                    # The data to send can be given in either @args[:message], @args[:content], or the
                    # combination of @args[:header] and @args[:body].
            Severity: Minor
            Found in lib/em/protocols/smtpclient.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 future has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                  def self.future arg, cb=nil, eb=nil, &blk
                    arg = arg.call if arg.respond_to?(:call)
            
                    if arg.respond_to?(:set_deferred_status)
                      if cb || eb
            Severity: Minor
            Found in lib/em/future.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 bind_connect has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.bind_connect bind_addr, bind_port, server, port=nil, handler=nil, *args
                begin
                  port = Integer(port)
                rescue ArgumentError, TypeError
                  # there was no port, so server must be a unix domain socket
            Severity: Minor
            Found in lib/eventmachine.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 currentEvents has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                private int currentEvents() {
                    int events = 0;
            
                    if (bWatchOnly)
                    {
            Severity: Minor
            Found in java/src/com/rubyeventmachine/EventableSocketChannel.java - 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 process_cmd has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                  def process_cmd line
                    case line.strip
                    when /^VALUE\s+(.+?)\s+(\d+)\s+(\d+)/ # VALUE <key> <flags> <bytes>
                      bytes = Integer($3)
                      # set_binary_mode bytes+2
            Severity: Minor
            Found in lib/em/protocols/memcache.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 close has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                void close() {
                    try {
                        if (mySelector != null)
                            mySelector.close();
                    } catch (IOException e) {}
            Severity: Minor
            Found in java/src/com/rubyeventmachine/EmReactor.java - About 1 hr to fix

              Method receive_line has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def receive_line ln
                      @@parms[:verbose] and $>.puts ">>> #{ln}"
              
                      return process_data_line(ln) if @state.include?(:data)
                      return process_auth_line(ln) if @state.include?(:auth_incomplete)
              Severity: Minor
              Found in lib/em/protocols/smtpserver.rb - About 1 hr to fix

                Method receive_data has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def receive_data data
                        if @lbp_mode == :lines
                          begin
                            @lpb_buffer.extract(data).each do |line|
                              receive_line(line.chomp) if respond_to?(:receive_line)
                Severity: Minor
                Found in lib/em/protocols/line_and_text.rb - About 1 hr to fix

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

                        def receive_data data
                          @sasl_data << data
                  
                          while @sasl_data.length > 2
                            len = (@sasl_data[0,2].unpack("n")).first
                  Severity: Minor
                  Found in lib/em/protocols/saslauth.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 writeOutboundData has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public boolean writeOutboundData() {
                          while (!outboundQ.isEmpty()) {
                              Packet p = outboundQ.getFirst();
                              int written = 0;
                              try {
                  Severity: Minor
                  Found in java/src/com/rubyeventmachine/EventableDatagramChannel.java - 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

                  Severity
                  Category
                  Status
                  Source
                  Language