Showing 15 of 15 total issues

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

  def run
    loop do
      if defined?(JRuby) || defined?(Rubinius) || @mode == :prefork || @mode == :threaded
        data, sender = @socket.recvfrom(1152)
        port, _, host = sender[1..3]
Severity: Minor
Found in experiments/concurrency/stub.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 respond has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

      def respond(exchange, env = nil)
        block_enabled = @options[:Block] && exchange.get?

        if block_enabled
          # Fail if m set.
Severity: Minor
Found in lib/david/server/respond.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

Class Exchange has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Exchange < Struct.new(:host, :port, :message, :ancillary, :options)
    include Registry
   
    def accept
      message.options[:accept]
Severity: Minor
Found in lib/david/exchange.rb - About 3 hrs to fix

    Method _call has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def _call(env)
          if env['REQUEST_METHOD'] != 'GET'
            return [405, {}, ['']]
          end
    
    
    Severity: Major
    Found in lib/rack/hello_world.rb - About 2 hrs to fix

      Method respond has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def respond(exchange, env = nil)
              block_enabled = @options[:Block] && exchange.get?
      
              if block_enabled
                # Fail if m set.
      Severity: Major
      Found in lib/david/server/respond.rb - About 2 hrs to fix

        Method run has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def run
            loop do
              if defined?(JRuby) || defined?(Rubinius) || @mode == :prefork || @mode == :threaded
                data, sender = @socket.recvfrom(1152)
                port, _, host = sender[1..3]
        Severity: Minor
        Found in experiments/concurrency/stub.rb - About 1 hr to fix

          Method register has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def register(controller, options)
                name    = controller.controller_name
                default = options.delete(:default)
          
                routes_hash.each do |link, route|
          Severity: Minor
          Found in lib/david/resource_discovery.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 basic_env has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def basic_env(exchange)
                  m = exchange.message
          
                  {
                    REMOTE_ADDR       => exchange.host,
          Severity: Minor
          Found in lib/david/server/respond.rb - About 1 hr to fix

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

                def dispatch(*args)
                  data, sender, _, anc = args
            
                  if jruby_or_rbx?
                    port, _, host = sender[1..3]
            Severity: Minor
            Found in lib/david/server.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 default has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.default(options = {})
                  # Guess.
                  if ENV.include?("PHP_FCGI_CHILDREN")
                    Rack::Handler::FastCGI
                  elsif ENV.include?(REQUEST_METHOD)
            Severity: Minor
            Found in lib/david/guerilla/rack/handler.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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def run
                  loop do
                    if jruby_or_rbx?
                      dispatch(*@socket.recvfrom(1152))
                    else
            Severity: Minor
            Found in lib/david/server.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 normalize_host has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def normalize_host(host)
                  ip = IPAddr.new(host)
            
                  if ipv6? && ip.ipv4?
                    ip = ip.ipv4_mapped
            Severity: Minor
            Found in lib/david/transmitter.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 multicast_initialize! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def multicast_initialize!
                    @socket.to_io.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, 1)
            
                    if ipv6?
                      maddrs = @options[:MulticastGroups]
            Severity: Minor
            Found in lib/david/server/multicast.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 error(exchange, 4.06) if exchange.accept && exchange.accept != cf
            Severity: Major
            Found in lib/david/server/respond.rb - About 30 mins to fix

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

                  def multicast?
                    a = ancillary
                    return false if a.nil?
              
                    return @multicast unless @multicast.nil?
              Severity: Minor
              Found in lib/david/exchange.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