eventmachine/eventmachine

Very high overall complexity: 1035

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'
Found in EventMachine - About 1 wk to fix

When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

Refactorings

Further Reading

Identical code found in 3 other locations

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 3 other locations - About 2 days to fix
examples/guides/getting_started/03_simple_chat_server.rb on lines 47..57
examples/guides/getting_started/07_simple_chat_server_step_four.rb on lines 49..59
examples/guides/getting_started/08_simple_chat_server_step_five.rb on lines 47..57

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

Refactorings

Further Reading

Identical code found in 3 other locations

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 3 other locations - About 2 days to fix
examples/guides/getting_started/06_simple_chat_server_step_three.rb on lines 49..59
examples/guides/getting_started/07_simple_chat_server_step_four.rb on lines 49..59
examples/guides/getting_started/08_simple_chat_server_step_five.rb on lines 47..57

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

Refactorings

Further Reading

Identical code found in 3 other locations

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 3 other locations - About 2 days to fix
examples/guides/getting_started/03_simple_chat_server.rb on lines 47..57
examples/guides/getting_started/06_simple_chat_server_step_three.rb on lines 49..59
examples/guides/getting_started/07_simple_chat_server_step_four.rb on lines 49..59

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

Refactorings

Further Reading

Identical code found in 3 other locations

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 3 other locations - About 2 days to fix
examples/guides/getting_started/03_simple_chat_server.rb on lines 47..57
examples/guides/getting_started/06_simple_chat_server_step_three.rb on lines 49..59
examples/guides/getting_started/08_simple_chat_server_step_five.rb on lines 47..57

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

Refactorings

Further Reading

Very complex method in .event_callback

  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.
Found in EventMachine - About 2 days to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Very complex method in #receive_data

      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.
Found in EventMachine::Protocols::HttpClient - About 1 day to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Identical code found in 1 other location

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 1 other location - About 1 day to fix
examples/guides/getting_started/08_simple_chat_server_step_five.rb on lines 86..93

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

Refactorings

Further Reading

Identical code found in 1 other location

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 1 other location - About 1 day to fix
examples/guides/getting_started/03_simple_chat_server.rb on lines 86..93

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

Refactorings

Further Reading

Very complex method in #start_tls

  #   EventMachine.run do
  #     EventMachine.add_shutdown_hook { puts "b" }
  #     EventMachine.add_shutdown_hook { puts "a" }
  #     EventMachine.stop
  #   end
Found in EventMachine - About 1 day to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

High overall complexity: 245

#--
#
# Author:: Francis Cianfrocca (gmail: blackhedd)
# Homepage::  http://rubyeventmachine.com
# Date:: 16 July 2006
Found in EventMachine::Protocols::SmtpServer - About 1 day to fix

When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

Refactorings

Further Reading

High overall complexity: 244

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer - About 1 day to fix

When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

Refactorings

Further Reading

High overall complexity: 221

#--
#
# Author:: Francis Cianfrocca (gmail: blackhedd)
# Homepage::  http://rubyeventmachine.com
# Date:: 16 July 2006
Found in EventMachine::Protocols::SmtpClient - About 1 day to fix

When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

Refactorings

Further Reading

Identical code found in 2 other locations

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 2 other locations - About 1 day to fix
examples/guides/getting_started/03_simple_chat_server.rb on lines 122..123
examples/guides/getting_started/08_simple_chat_server_step_five.rb on lines 122..123

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

Refactorings

Further Reading

Identical code found in 2 other locations

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 2 other locations - About 1 day to fix
examples/guides/getting_started/07_simple_chat_server_step_four.rb on lines 102..103
examples/guides/getting_started/08_simple_chat_server_step_five.rb on lines 122..123

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

Refactorings

Further Reading

Identical code found in 2 other locations

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 2 other locations - About 1 day to fix
examples/guides/getting_started/03_simple_chat_server.rb on lines 122..123
examples/guides/getting_started/07_simple_chat_server_step_four.rb on lines 102..103

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

Refactorings

Further Reading

Very complex method in #send_request

      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
Found in EventMachine::Protocols::HttpClient - About 1 day to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

High overall complexity: 215

#--
#
# Author:: Francis Cianfrocca (gmail: blackhedd)
# Homepage::  http://rubyeventmachine.com
# Date:: 16 July 2006
Found in EventMachine::Protocols::HttpClient - About 1 day to fix

When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

Refactorings

Further Reading

Very complex method in #set_tls_parms


  # Clean up Ruby space following a release_machine
  def self.cleanup_machine
    if @threadpool && !@threadpool.empty?
      # Tell the threads to stop
Found in EventMachine - About 1 day to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Identical code found in 1 other location

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 1 other location - About 7 hrs to fix
examples/guides/getting_started/03_simple_chat_server.rb on lines 110..113

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

Refactorings

Further Reading

Identical code found in 1 other location

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 1 other location - About 7 hrs to fix
examples/guides/getting_started/08_simple_chat_server_step_five.rb on lines 110..113

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

Refactorings

Further Reading

Complex method in #receive_data

      def receive_data data
        return unless (data and data.length > 0)

        # Do this stuff in lieu of a constructor.
        @lt2_mode ||= :lines
Found in EventMachine::Protocols::LineText2 - About 6 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in #receive_data_response

      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].
Found in EventMachine::Protocols::SmtpClient - About 6 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Identical code found in 1 other location

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 1 other location - About 6 hrs to fix
examples/guides/getting_started/03_simple_chat_server.rb on lines 70..77

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

Refactorings

Further Reading

Identical code found in 1 other location

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 1 other location - About 6 hrs to fix
examples/guides/getting_started/08_simple_chat_server_step_five.rb on lines 70..77

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

Refactorings

Further Reading

Identical code found in 1 other location

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'
Found in EventMachine and 1 other location - About 6 hrs to fix
lib/eventmachine.rb on lines 517..526

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

Refactorings

Further Reading

Identical code found in 1 other location

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'
Found in EventMachine and 1 other location - About 6 hrs to fix
lib/eventmachine.rb on lines 661..670

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

Refactorings

Further Reading

Complex method in #dispatch_conn_message

      def dispatch_conn_message msg
        case msg
        when AuthentificationClearTextPassword
          raise ArgumentError, "no password specified" if @password.nil?
          send_data PasswordMessage.new(@password).dump
Found in EventMachine::Protocols::Postgres3 - About 6 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in #each

    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
Found in EventMachine::Iterator - About 5 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in #start_tls

    def start_tls args={}
      priv_key     = args[:private_key_file]
      cert_chain   = args[:cert_chain_file]
      verify_peer  = args[:verify_peer]
      sni_hostname = args[:sni_hostname]
Found in EventMachine::Connection - About 5 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in .run

  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
Found in EventMachine - About 5 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Similar code found in 1 other location

require 'em/pure_ruby' if ENV['EM_PURE_RUBY']
require 'eventmachine'
require 'test/unit'
require 'rbconfig'
require 'socket'
Found in Test::Unit::TestCase and 1 other location - About 4 hrs to fix
tests/em_test_helper.rb on lines 134..142

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

Refactorings

Further Reading

Similar code found in 1 other location

require 'em/pure_ruby' if ENV['EM_PURE_RUBY']
require 'eventmachine'
require 'test/unit'
require 'rbconfig'
require 'socket'
Found in Test::Unit::TestCase and 1 other location - About 4 hrs to fix
tests/em_test_helper.rb on lines 144..152

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

Refactorings

Further Reading

Similar code found in 1 other location

#--
#
# Author:: Francis Cianfrocca (gmail: blackhedd)
# Homepage::  http://rubyeventmachine.com
# Date:: 16 Jul 2006
Found in EventMachine::Deferrable and 1 other location - About 4 hrs to fix
lib/em/deferrable.rb on lines 44..53

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

Refactorings

Further Reading

Similar code found in 1 other location

#--
#
# Author:: Francis Cianfrocca (gmail: blackhedd)
# Homepage::  http://rubyeventmachine.com
# Date:: 16 Jul 2006
Found in EventMachine::Deferrable and 1 other location - About 4 hrs to fix
lib/em/deferrable.rb on lines 70..79

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

Refactorings

Further Reading

Complex method in #receive_data

      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)
Found in EventMachine::Protocols::LineAndTextProtocol - About 4 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in #process_data_line

      def process_data_line ln
        if ln == "."
          if @databuffer.length > 0
            receive_data_chunk @databuffer
            @databuffer.clear
Found in EventMachine::Protocols::SmtpServer - About 3 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in #process_header

        def process_header
          unless @header_lines.first =~ HttpResponseRE
            @conn.close_connection
            @internal_error = :bad_request
          end
Found in EventMachine::Protocols::HttpClient2::Request - About 3 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Similar code found in 7 other locations

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in EchoServer and 7 other locations - About 3 hrs to fix
examples/guides/getting_started/01_eventmachine_echo_server.rb on lines 12..18
examples/guides/getting_started/03_simple_chat_server.rb on lines 143..149
examples/guides/getting_started/04_simple_chat_server_step_one.rb on lines 21..27
examples/guides/getting_started/05_simple_chat_server_step_two.rb on lines 37..43
examples/guides/getting_started/06_simple_chat_server_step_three.rb on lines 92..98
examples/guides/getting_started/07_simple_chat_server_step_four.rb on lines 115..121
examples/guides/getting_started/08_simple_chat_server_step_five.rb on lines 135..141

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

Refactorings

Further Reading

Similar code found in 7 other locations

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in EchoServer and 7 other locations - About 3 hrs to fix
examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb on lines 16..22
examples/guides/getting_started/03_simple_chat_server.rb on lines 143..149
examples/guides/getting_started/04_simple_chat_server_step_one.rb on lines 21..27
examples/guides/getting_started/05_simple_chat_server_step_two.rb on lines 37..43
examples/guides/getting_started/06_simple_chat_server_step_three.rb on lines 92..98
examples/guides/getting_started/07_simple_chat_server_step_four.rb on lines 115..121
examples/guides/getting_started/08_simple_chat_server_step_five.rb on lines 135..141

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

Refactorings

Further Reading

Similar code found in 7 other locations

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 7 other locations - About 3 hrs to fix
examples/guides/getting_started/01_eventmachine_echo_server.rb on lines 12..18
examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb on lines 16..22
examples/guides/getting_started/03_simple_chat_server.rb on lines 143..149
examples/guides/getting_started/04_simple_chat_server_step_one.rb on lines 21..27
examples/guides/getting_started/05_simple_chat_server_step_two.rb on lines 37..43
examples/guides/getting_started/07_simple_chat_server_step_four.rb on lines 115..121
examples/guides/getting_started/08_simple_chat_server_step_five.rb on lines 135..141

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

Refactorings

Further Reading

Similar code found in 7 other locations

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 7 other locations - About 3 hrs to fix
examples/guides/getting_started/01_eventmachine_echo_server.rb on lines 12..18
examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb on lines 16..22
examples/guides/getting_started/03_simple_chat_server.rb on lines 143..149
examples/guides/getting_started/04_simple_chat_server_step_one.rb on lines 21..27
examples/guides/getting_started/06_simple_chat_server_step_three.rb on lines 92..98
examples/guides/getting_started/07_simple_chat_server_step_four.rb on lines 115..121
examples/guides/getting_started/08_simple_chat_server_step_five.rb on lines 135..141

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

Refactorings

Further Reading

Similar code found in 7 other locations

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 7 other locations - About 3 hrs to fix
examples/guides/getting_started/01_eventmachine_echo_server.rb on lines 12..18
examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb on lines 16..22
examples/guides/getting_started/04_simple_chat_server_step_one.rb on lines 21..27
examples/guides/getting_started/05_simple_chat_server_step_two.rb on lines 37..43
examples/guides/getting_started/06_simple_chat_server_step_three.rb on lines 92..98
examples/guides/getting_started/07_simple_chat_server_step_four.rb on lines 115..121
examples/guides/getting_started/08_simple_chat_server_step_five.rb on lines 135..141

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

Refactorings

Further Reading

Similar code found in 7 other locations

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 7 other locations - About 3 hrs to fix
examples/guides/getting_started/01_eventmachine_echo_server.rb on lines 12..18
examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb on lines 16..22
examples/guides/getting_started/03_simple_chat_server.rb on lines 143..149
examples/guides/getting_started/05_simple_chat_server_step_two.rb on lines 37..43
examples/guides/getting_started/06_simple_chat_server_step_three.rb on lines 92..98
examples/guides/getting_started/07_simple_chat_server_step_four.rb on lines 115..121
examples/guides/getting_started/08_simple_chat_server_step_five.rb on lines 135..141

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

Refactorings

Further Reading

Similar code found in 7 other locations

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 7 other locations - About 3 hrs to fix
examples/guides/getting_started/01_eventmachine_echo_server.rb on lines 12..18
examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb on lines 16..22
examples/guides/getting_started/03_simple_chat_server.rb on lines 143..149
examples/guides/getting_started/04_simple_chat_server_step_one.rb on lines 21..27
examples/guides/getting_started/05_simple_chat_server_step_two.rb on lines 37..43
examples/guides/getting_started/06_simple_chat_server_step_three.rb on lines 92..98
examples/guides/getting_started/07_simple_chat_server_step_four.rb on lines 115..121

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

Refactorings

Further Reading

Similar code found in 7 other locations

#!/usr/bin/env ruby

require 'rubygems' # or use Bundler.setup
require 'eventmachine'

Found in SimpleChatServer and 7 other locations - About 3 hrs to fix
examples/guides/getting_started/01_eventmachine_echo_server.rb on lines 12..18
examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb on lines 16..22
examples/guides/getting_started/03_simple_chat_server.rb on lines 143..149
examples/guides/getting_started/04_simple_chat_server_step_one.rb on lines 21..27
examples/guides/getting_started/05_simple_chat_server_step_two.rb on lines 37..43
examples/guides/getting_started/06_simple_chat_server_step_three.rb on lines 92..98
examples/guides/getting_started/08_simple_chat_server_step_five.rb on lines 135..141

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

Refactorings

Further Reading

Complex method in #receive_line

      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)
Found in EventMachine::Protocols::SmtpServer - About 3 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in #receive_line

      def receive_line line
        case @hc_mode
        when :discard_blanks
          unless line == ""
            @hc_mode = :headers

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in .klass_from_handler

  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
Found in EventMachine - About 3 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in .attach_fd

  # (Normally, {EventMachine.run} keeps running indefinitely, even after the block supplied to it
  # finishes running, until user code calls {EventMachine.stop})
  #
  def self.run_block &block
    pr = proc {
Found in EventMachine - About 3 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More