eventmachine/eventmachine

View on GitHub

Showing 131 of 147 total issues

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

    Method handshake_complete? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def handshake_complete?
          if !@handshake_complete && io.respond_to?(:state)
            if io.state =~ /^SSLOK/
              @handshake_complete = true
              EventMachine::event_callback uuid, SslHandshakeCompleted, ""
    Severity: Minor
    Found in lib/em/pure_ruby.rb - About 45 mins 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 sendDatagram has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        void sendDatagram (long sig, byte[] data, int length, String recipAddress, int recipPort);
    Severity: Minor
    Found in java/src/com/rubyeventmachine/EmReactorInterface.java - About 35 mins to fix

      Method send_datagram has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def send_datagram target, data, datalength, host, port
      Severity: Minor
      Found in lib/em/pure_ruby.rb - About 35 mins to fix

        Method connect has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def self.connect server, port=nil, handler=nil, *args, &blk
        Severity: Minor
        Found in lib/eventmachine.rb - About 35 mins to fix

          Method send_datagram has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def self.send_datagram sig, data, length, address, port
          Severity: Minor
          Found in lib/jeventmachine.rb - About 35 mins to fix

            Method sendDatagram has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public void sendDatagram(long sig, byte[] data, int length, String recipAddress, int recipPort)
            Severity: Minor
            Found in java/src/com/rubyeventmachine/NullEmReactor.java - About 35 mins to fix

              Method start_server has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def self.start_server server, port=nil, handler=nil, *args, &block
              Severity: Minor
              Found in lib/eventmachine.rb - About 35 mins to fix

                Method sendDatagram has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public void sendDatagram (long sig, byte[] data, int length, String recipAddress, int recipPort) {
                Severity: Minor
                Found in java/src/com/rubyeventmachine/EmReactor.java - About 35 mins to fix

                  Method removeUnboundConnections has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      void removeUnboundConnections() {
                          ListIterator<Long> iter = UnboundConnections.listIterator(0);
                          while (iter.hasNext()) {
                              long b = iter.next();
                  
                  
                  Severity: Minor
                  Found in java/src/com/rubyeventmachine/EmReactor.java - About 35 mins 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_starttls has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def process_starttls
                          if @@parms[:starttls]
                            if @state.include?(:starttls)
                              send_data "503 TLS Already negotiated\r\n"
                            elsif ! @state.include?(:ehlo)
                  Severity: Minor
                  Found in lib/em/protocols/smtpserver.rb - About 35 mins 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 checkIO has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      void checkIO() {
                          long timeout;
                  
                          if (NewConnections.size() > 0) {
                              timeout = -1;
                  Severity: Minor
                  Found in java/src/com/rubyeventmachine/EmReactor.java - About 35 mins 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 request has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def request args
                          args[:host_header] = @host_header unless args.has_key?(:host_header)
                          args[:authorization] = @authorization unless args.has_key?(:authorization)
                          r = Request.new self, args
                          if @closed
                  Severity: Minor
                  Found in lib/em/protocols/httpclient2.rb - About 35 mins 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 addNewConnections has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      void addNewConnections() {
                          ListIterator<EventableSocketChannel> iter = DetachedConnections.listIterator(0);
                          while (iter.hasNext()) {
                              EventableSocketChannel ec = iter.next();
                              ec.cleanup();
                  Severity: Minor
                  Found in java/src/com/rubyeventmachine/EmReactor.java - About 35 mins 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 attach_io has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def EventMachine::attach_io io, watch_mode, handler=nil, *args
                      klass = klass_from_handler(Connection, handler, *args)
                  
                      if !watch_mode and klass.public_instance_methods.any?{|m| [:notify_readable, :notify_writable].include? m.to_sym }
                        raise ArgumentError, "notify_readable/writable with EM.attach is not supported. Use EM.watch(io){ |c| c.notify_readable = true }"
                  Severity: Minor
                  Found in lib/eventmachine.rb - About 35 mins 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 schedule has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def schedule
                        EM.next_tick do
                          next if @stopped
                          if @work.call == :stop
                            stop
                  Severity: Minor
                  Found in lib/em/tick_loop.rb - About 35 mins 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 push has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def push(*items)
                        EM.schedule do
                          @sink.push(*items)
                          unless @popq.empty?
                            @drain = @sink
                  Severity: Minor
                  Found in lib/em/queue.rb - About 35 mins 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

                  Avoid too many return statements within this method.
                  Open

                      return true
                  Severity: Major
                  Found in lib/eventmachine.rb - About 30 mins to fix

                    Method errback has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def errback &block
                          return unless block
                          @deferred_status ||= :unknown
                          if @deferred_status == :failed
                            block.call(*@deferred_args)
                    Severity: Minor
                    Found in lib/em/deferrable.rb - About 25 mins 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 reconnect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def self.reconnect server, port, handler
                        # Observe, the test for already-connected FAILS if we call a reconnect inside post_init,
                        # because we haven't set up the connection in @conns by that point.
                        # RESIST THE TEMPTATION to "fix" this problem by redefining the behavior of post_init.
                        #
                    Severity: Minor
                    Found in lib/eventmachine.rb - About 25 mins 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