eventmachine/eventmachine

View on GitHub

Showing 147 of 147 total issues

Method run has a Cognitive Complexity of 22 (exceeds 5 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 3 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 receive_data has 74 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def receive_data data
        while data and data.length > 0
          case @read_state
          when :base
            # Perform any per-request initialization here and don't consume any data.
Severity: Major
Found in lib/em/protocols/httpclient.rb - About 2 hrs to fix

    File EventableSocketChannel.java has 289 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * $Id$
     * 
     * Author:: Francis Cianfrocca (gmail: blackhedd)
     * Homepage::  http://rubyeventmachine.com
    Severity: Minor
    Found in java/src/com/rubyeventmachine/EventableSocketChannel.java - About 2 hrs to fix

      Class SmtpClient has 25 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class SmtpClient < Connection
            include EventMachine::Deferrable
            include EventMachine::Protocols::LineText2
      
            def initialize
      Severity: Minor
      Found in lib/em/protocols/smtpclient.rb - About 2 hrs to fix

        Method event_callback has 70 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.event_callback conn_binding, opcode, data
            #
            # Changed 27Dec07: Eliminated the hookable error handling.
            # No one was using it, and it degraded performance significantly.
            # It's in original_event_callback, which is dead code.
        Severity: Major
        Found in lib/eventmachine.rb - About 2 hrs to fix

          Method stream_one_chunk has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              def stream_one_chunk
                loop do
                  if @io.eof?
                    @connection.send_data "0\r\n\r\n" if @http_chunks
                    succeed
          Severity: Minor
          Found in lib/em/io_streamer.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 send_request has a Cognitive Complexity of 19 (exceeds 5 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 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 spawn_threadpool has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.spawn_threadpool
              until @threadpool.size == @threadpool_size.to_i
                thread = Thread.new do
                  Thread.current.abort_on_exception = true
                  while true
          Severity: Minor
          Found in lib/eventmachine.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 start_tls has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def start_tls args={}
                priv_key_path   = args[:private_key_file]
                priv_key        = args[:private_key]
                priv_key_pass   = args[:private_key_pass]
                cert_chain_path = args[:cert_chain_file]
          Severity: Major
          Found in lib/em/connection.rb - About 2 hrs to fix

            Method set_deferred_status has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                def set_deferred_status status, *args
                  cancel_timeout
                  @errbacks ||= nil
                  @callbacks ||= nil
                  @deferred_status = status
            Severity: Minor
            Found in lib/em/deferrable.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 start_tls has 55 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def start_tls signature
                  selectable = Reactor.instance.get_selectable(signature) or raise "unknown io selectable for start_tls"
                  tls_parms = @tls_parms[signature]
                  ctx = OpenSSL::SSL::SSLContext.new
                  ctx.options = tls_parms[:ssl_options]
            Severity: Major
            Found in lib/em/pure_ruby.rb - About 2 hrs to fix

              Method writeOutboundData has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                  public boolean writeOutboundData() throws IOException {
                      ByteBuffer[] bufs = new ByteBuffer[64];
                      int i;
                      long written, toWrite;
                      while (!outboundQ.isEmpty()) {
              Severity: Minor
              Found in java/src/com/rubyeventmachine/EventableSocketChannel.java - 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 close has a Cognitive Complexity of 16 (exceeds 5 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 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 process_header has a Cognitive Complexity of 16 (exceeds 5 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 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 set_tls_parms has a Cognitive Complexity of 16 (exceeds 5 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
                    bitmask = protocols_bitmask
                    ssl_options = OpenSSL::SSL::OP_ALL
                    ssl_options |= OpenSSL::SSL::OP_NO_SSLv2 if defined?(OpenSSL::SSL::OP_NO_SSLv2) && EM_PROTO_SSLv2 & bitmask == 0
                    ssl_options |= OpenSSL::SSL::OP_NO_SSLv3 if defined?(OpenSSL::SSL::OP_NO_SSLv3) && EM_PROTO_SSLv3 & bitmask == 0
              Severity: Minor
              Found in lib/em/pure_ruby.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 consume_line has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                      def consume_line line
                        if @state == :precommand
                          unless line =~ /\A\s*\Z/
                            @command = line
                            @state = :headers
              Severity: Minor
              Found in lib/em/protocols/stomp.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 receive_data has 50 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def receive_data data
                      return unless (data and data.length > 0)
              
                      # Do this stuff in lieu of a constructor.
                      @lt2_mode ||= :lines
              Severity: Minor
              Found in lib/em/protocols/linetext2.rb - About 2 hrs to fix

                Method receive_data has a Cognitive Complexity of 15 (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
                          raise "SASL Max Field Length exceeded" if len > MaxFieldSize
                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 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 process_data_line has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                      def process_data_line ln
                        if ln == "."
                          if @databuffer.length > 0
                            receive_data_chunk @databuffer
                            @databuffer.clear
                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

                Severity
                Category
                Status
                Source
                Language