eventmachine/eventmachine

View on GitHub

File pure_ruby.rb has 849 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'singleton'
require 'forwardable'
require 'socket'
require 'fcntl'
require 'set'
Severity: Major
Found in lib/em/pure_ruby.rb - About 2 days to fix

    Method receive_data has a Cognitive Complexity of 55 (exceeds 5 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: Minor
    Found in lib/em/protocols/httpclient.rb - About 1 day 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 eventmachine.rb has 522 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    if defined?(EventMachine.library_type) and EventMachine.library_type == :pure_ruby
      # assume 'em/pure_ruby' was loaded already
    elsif RUBY_PLATFORM =~ /java/
      require 'java'
      require 'jeventmachine'
    Severity: Major
    Found in lib/eventmachine.rb - About 1 day to fix

      Method event_callback has a Cognitive Complexity of 48 (exceeds 5 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: Minor
      Found in lib/eventmachine.rb - About 7 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 EmReactor.java has 467 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/EmReactor.java - About 7 hrs to fix

        EmReactor has 46 methods (exceeds 20 allowed). Consider refactoring.
        Open

        public class EmReactor {
            public final int EM_TIMER_FIRED = 100;
            public final int EM_CONNECTION_READ = 101;
            public final int EM_CONNECTION_UNBOUND = 102;
            public final int EM_CONNECTION_ACCEPTED = 103;
        Severity: Minor
        Found in java/src/com/rubyeventmachine/EmReactor.java - About 6 hrs to fix

          Class Connection has 46 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class Connection
              # @private
              attr_accessor :signature
          
              # @private
          Severity: Minor
          Found in lib/em/connection.rb - About 6 hrs to fix

            Method receive_data has a Cognitive Complexity of 37 (exceeds 5 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 5 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

            Class SmtpServer has 37 methods (exceeds 20 allowed). Consider refactoring.
            Open

                class SmtpServer < EventMachine::Connection
                  include Protocols::LineText2
            
                  HeloRegex = /\AHELO\s*/i
                  EhloRegex = /\AEHLO\s*/i
            Severity: Minor
            Found in lib/em/protocols/smtpserver.rb - About 4 hrs to fix

              Method receive_line has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
              Open

                    def receive_line line
                      case @hc_mode
                      when :discard_blanks
                        unless line == ""
                          @hc_mode = :headers
              Severity: Minor
              Found in lib/em/protocols/header_and_content.rb - About 4 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 each has a Cognitive Complexity of 27 (exceeds 5 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 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

              EventableSocketChannel has 31 methods (exceeds 20 allowed). Consider refactoring.
              Open

              public class EventableSocketChannel implements EventableChannel {
                  Selector selector;
                  SelectionKey channelKey;
                  SocketChannel channel;
              
              
              Severity: Minor
              Found in java/src/com/rubyeventmachine/EventableSocketChannel.java - About 3 hrs to fix

                File smtpserver.rb has 319 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                module EventMachine
                  module Protocols
                
                    # This is a protocol handler for the server side of SMTP.
                    # It's NOT a complete SMTP server obeying all the semantics of servers conforming to
                Severity: Minor
                Found in lib/em/protocols/smtpserver.rb - About 3 hrs to fix

                  File httpclient2.rb has 316 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  module EventMachine
                    module Protocols
                  
                      # <b>Note:</b> This class is deprecated and will be removed. Please use EM-HTTP-Request instead.
                      #
                  Severity: Minor
                  Found in lib/em/protocols/httpclient2.rb - About 3 hrs to fix

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

                        def stream_one_chunk
                          loop {
                            if @position < @size
                              if @connection.get_outbound_data_size > BackpressureLevel
                                EventMachine::next_tick {stream_one_chunk}
                    Severity: Minor
                    Found in lib/em/streamer.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 a Cognitive Complexity of 24 (exceeds 5 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 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 start_tls has a Cognitive Complexity of 24 (exceeds 5 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: Minor
                    Found in lib/em/pure_ruby.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 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
                        Severity
                        Category
                        Status