celluloid/celluloid-dns

View on GitHub

Showing 14 of 14 total issues

Method create has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

            def self.create(arg)
                case arg
                when IPv6
                    return arg
                when String
Severity: Minor
Found in lib/celluloid/dns/extensions/resolv.rb - About 2 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 dispatch_request has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

        def dispatch_request(message)
            request = Request.new(message, @servers)
            
            request.each do |server|
                @logger.debug "[#{message.id}] Sending request #{message.question.inspect} to server #{server.inspect}" if @logger
Severity: Minor
Found in lib/celluloid/dns/resolver.rb - About 2 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 addresses_for has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

        def addresses_for(name, resource_class = Resolv::DNS::Resource::IN::A, options = {})
            name = fully_qualified_name(name)
            
            cache = options.fetch(:cache, {})
            retries = options.fetch(:retries, DEFAULT_RETRIES)
Severity: Minor
Found in lib/celluloid/dns/resolver.rb - About 2 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 create has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            def self.create(arg)
                case arg
                when IPv6
                    return arg
                when String
Severity: Minor
Found in lib/celluloid/dns/extensions/resolv.rb - About 1 hr to fix

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

            def run
                @logger.info "Starting Celluloid::DNS server (v#{Celluloid::DNS::VERSION})..."
                
                fire(:setup)
                
    Severity: Minor
    Found in lib/celluloid/dns/server.rb - About 1 hr to fix

      Method addresses_for has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def addresses_for(name, resource_class = Resolv::DNS::Resource::IN::A, options = {})
                  name = fully_qualified_name(name)
                  
                  cache = options.fetch(:cache, {})
                  retries = options.fetch(:retries, DEFAULT_RETRIES)
      Severity: Minor
      Found in lib/celluloid/dns/resolver.rb - About 1 hr to fix

        Method process_query has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def process_query(query, options = {}, &block)
                    start_time = Time.now
                    
                    # Setup response
                    response = Resolv::DNS::Message::new(query.id)
        Severity: Minor
        Found in lib/celluloid/dns/server.rb - About 1 hr to fix

          Method passthrough! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                  def passthrough!(resolver, options = {}, &block)
                      if @query.rd || options[:force] || options[:name]
                          response = passthrough(resolver, options)
                          
                          if response
          Severity: Minor
          Found in lib/celluloid/dns/transaction.rb - About 55 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 valid_response has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                  def valid_response(message, response)
                      if response.tc != 0
                          @logger.warn "[#{message.id}] Received truncated response!" if @logger
                      elsif response.id != message.id
                          @logger.warn "[#{message.id}] Received response with incorrect message id: #{response.id}!" if @logger
          Severity: Minor
          Found in lib/celluloid/dns/resolver.rb - About 55 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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  def initialize(server, query, question, resource_class, response, options = {})
          Severity: Minor
          Found in lib/celluloid/dns/transaction.rb - About 45 mins to fix

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

                    def run
                        @logger.info "Starting Celluloid::DNS server (v#{Celluloid::DNS::VERSION})..."
                        
                        fire(:setup)
                        
            Severity: Minor
            Found in lib/celluloid/dns/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

            Avoid deeply nested control flow statements.
            Open

                                    if (0..255) === a && (0..255) === b && (0..255) === c && (0..255) === d
                                        a1 = ''.b
                                        a2 = ''.b
                                        prefix.scan(/[0-9A-Fa-f]+/) {|hex| a1 << [hex.hex].pack('n')}
                                        suffix.scan(/[0-9A-Fa-f]+/) {|hex| a2 << [hex.hex].pack('n')}
            Severity: Major
            Found in lib/celluloid/dns/extensions/resolv.rb - About 45 mins to fix

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

                  def self.decode_message(data)
                      # Otherwise the decode process might fail with non-binary data.
                      if data.respond_to? :force_encoding
                          data.force_encoding("BINARY")
                      end
              Severity: Minor
              Found in lib/celluloid/dns/message.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 fully_qualified_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                      def fully_qualified_name(name)
                          # If we are passed an existing deconstructed name:
                          if Resolv::DNS::Name === name
                              if name.absolute?
                                  return name
              Severity: Minor
              Found in lib/celluloid/dns/resolver.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