eventmachine/eventmachine

View on GitHub

Showing 26 of 147 total issues

File pure_ruby.rb has 863 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

    File eventmachine.rb has 527 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 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

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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    public Object[] getPeerName (long sig) {
                        EventableChannel channel = Connections.get(sig);
                        if (channel != null) {
                            return Connections.get(sig).getPeerName();
                        }
                Severity: Major
                Found in java/src/com/rubyeventmachine/EmReactor.java and 1 other location - About 1 hr to fix
                java/src/com/rubyeventmachine/EmReactor.java on lines 553..563

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

                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

                    public Object[] getSockName (long sig) {
                        EventableChannel channel = Connections.get(sig);
                        if (channel != null) {
                            return Connections.get(sig).getSockName();
                        }
                Severity: Major
                Found in java/src/com/rubyeventmachine/EmReactor.java and 1 other location - About 1 hr to fix
                java/src/com/rubyeventmachine/EmReactor.java on lines 541..551

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

                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

                Avoid deeply nested control flow statements.
                Open

                              will_take = if remaining_data.length > needed
                                            needed
                                          else
                                            remaining_data.length
                                          end
                Severity: Major
                Found in lib/em/protocols/linetext2.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                if (m = data.match(/\A(\S*)\r\n/m))
                                  data = data[m[0].length..-1]
                                  @chunk_length = m[1].to_i(16)
                                  @chunk_read = 0
                                  if @chunk_length == 0
                  Severity: Major
                  Found in lib/em/protocols/httpclient.rb - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                elsif @content_length
                                  # If there was no content-length header, we have to wait until the connection
                                  # closes. Everything we get until that point is content.
                                  # TODO: Must impose a content-size limit, and also must implement chunking.
                                  # Also, must support either temporary files for large content, or calling
                    Severity: Major
                    Found in lib/em/protocols/httpclient.rb - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                            return if t == false # timer cancelled
                      Severity: Major
                      Found in lib/eventmachine.rb - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                        elsif find_openssl_library
                          # If we don't even need any options to find a usable OpenSSL, go with it
                          add_define 'WITH_SSL'
                        elsif dir_config_search('OpenSSL', 'openssl', ['/usr/local', '/opt/local', '/usr/local/opt/openssl']) do
                            find_openssl_library
                        Severity: Major
                        Found in ext/extconf.rb - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                            add_define 'WITH_SSL' if find_openssl_library
                          Severity: Major
                          Found in ext/extconf.rb - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                        rescue Exception => error
                                          @wrapped_exception = error
                                          stop
                            Severity: Major
                            Found in lib/eventmachine.rb - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                  elsif opcode == ConnectionData
                                    c = @conns[conn_binding] or raise ConnectionNotBound, "received data #{data} for unknown signature: #{conn_binding}"
                                    c.receive_data data
                                  elsif opcode == LoopbreakSignalled
                                    run_deferred_callbacks
                              Severity: Major
                              Found in lib/eventmachine.rb - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                              if k == "content-length"
                                                @content_length = v.to_i
                                              end
                                Severity: Major
                                Found in lib/em/protocols/stomp.rb - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                  if @headers.length == 1
                                                    parse_response_line
                                                  elsif ary.first =~ /\Acontent-length:\s*/i
                                                    # Only take the FIRST content-length header that appears,
                                                    # which we can distinguish because @content_length is nil.
                                  Severity: Major
                                  Found in lib/em/protocols/httpclient.rb - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                    if (@content_length and @content_length > 0) || @chunked || @connection_close
                                                      @read_state = :content
                                                    else
                                                      dispatch_response
                                                      @read_state = :base
                                    Severity: Major
                                    Found in lib/em/protocols/httpclient.rb - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language