Method parse_hosts_file
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def parse_hosts_file
path = %w[
%WINDIR%\system32\drivers\etc\hosts
/etc/hosts
/data/data/com.termux/files/usr/etc/hosts
- 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 add
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add(hostname, ip_address)
unless self.class.is_valid_hostname?(hostname)
# it is important to validate the hostname because assumptions about what characters it may contain are made
# when saving and loading it from the configuration
raise ::ArgumentError.new("Invalid hostname: #{hostname}")
- 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 delete
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def delete(hostname, ip_address)
ip_address = IPAddr.new(ip_address) if ip_address.is_a?(String) && Rex::Socket.is_ip_addr?(ip_address)
if ip_address.family == ::Socket::AF_INET
type = Dnsruby::Types::A
else
- 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"