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
- 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 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
- 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 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)
- 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 create
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.create(arg)
case arg
when IPv6
return arg
when String
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)
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)
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)
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
- 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 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
- 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 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(server, query, question, resource_class, response, options = {})
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)
- 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
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')}
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
- 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 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
- 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"