Method send_tcp
has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring. Open
def send_tcp(packet, packet_data, nameservers, prox = @config[:proxies])
ans = nil
length = [packet_data.size].pack("n")
nameservers.each do |ns, socket_options|
socket = nil
- Read upRead up
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
File resolver.rb
has 374 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'net/dns/resolver'
require 'dnsruby'
module Rex
module Proto
Method send_udp
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def send_udp(packet,packet_data, nameservers)
ans = nil
nameservers.each do |ns, socket_options|
begin
config = {
- Read upRead up
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 send_tcp
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
def send_tcp(packet, packet_data, nameservers, prox = @config[:proxies])
ans = nil
length = [packet_data.size].pack("n")
nameservers.each do |ns, socket_options|
socket = nil
Method resolve_via_dns_server
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def resolve_via_dns_server(upstream_resolver, packet, type, _cls)
method = self.use_tcp? ? :send_tcp : :send_udp
# Store packet_data for performance improvements,
# so methods don't keep on calling Packet#encode
- Read upRead up
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 send
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def send(argument, type = Dnsruby::Types::A, cls = Dnsruby::Classes::IN)
case argument
when Dnsruby::Message
packet = argument
when Net::DNS::Packet, Resolv::DNS::Message
Method send
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def send(argument, type = Dnsruby::Types::A, cls = Dnsruby::Classes::IN)
case argument
when Dnsruby::Message
packet = argument
when Net::DNS::Packet, Resolv::DNS::Message
- Read upRead up
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 a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def initialize(config = {})
raise ResolverArgumentError, "Argument has to be Hash" unless config.kind_of? Hash
# config.key_downcase!
@config = Defaults.merge config
@config[:config_file] ||= self.class.default_config_file
- Read upRead up
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 send_udp
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def send_udp(packet,packet_data, nameservers)
ans = nil
nameservers.each do |ns, socket_options|
begin
config = {
Method resolve_via_dns_server
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def resolve_via_dns_server(upstream_resolver, packet, type, _cls)
method = self.use_tcp? ? :send_tcp : :send_udp
# Store packet_data for performance improvements,
# so methods don't keep on calling Packet#encode
Method simple_name_lookup
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def simple_name_lookup(upstream_resolver, packet, type, cls, &block)
return nil unless cls == Dnsruby::Classes::IN
# todo: make sure this will work if the packet has multiple questions, figure out how that's handled
name = packet.question.first.qname.to_s
Method initialize
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(config = {})
raise ResolverArgumentError, "Argument has to be Hash" unless config.kind_of? Hash
# config.key_downcase!
@config = Defaults.merge config
@config[:config_file] ||= self.class.default_config_file
Method search
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def search(name, type = Dnsruby::Types::A, cls = Dnsruby::Classes::IN)
return query(name,type,cls) if name.class == IPAddr
# If the name contains at least one dot then try it as is first.
if name.include? "."
@logger.debug "Search(#{name},#{Dnsruby::Types.new(type)},#{Dnsruby::Classes.new(cls)})"
- Read upRead up
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 simple_name_lookup
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def simple_name_lookup(upstream_resolver, packet, type, cls, &block)
Method simple_name_lookup
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def simple_name_lookup(upstream_resolver, packet, type, cls, &block)
return nil unless cls == Dnsruby::Classes::IN
# todo: make sure this will work if the packet has multiple questions, figure out how that's handled
name = packet.question.first.qname.to_s
- Read upRead up
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"