Showing 7 of 9 total issues
Method ifconfig
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def self.ifconfig(iface='eth0')
ret = {}
iface = iface.to_s.scan(/[0-9A-Za-z]/).join # Sanitizing input, no spaces, semicolons, etc.
case RUBY_PLATFORM
when /linux/i
- 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 ifconfig
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.ifconfig(iface='eth0')
ret = {}
iface = iface.to_s.scan(/[0-9A-Za-z]/).join # Sanitizing input, no spaces, semicolons, etc.
case RUBY_PLATFORM
when /linux/i
Method whoami?
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def self.whoami?(args={})
unless args.kind_of? Hash
raise ArgumentError, "Argument to `whoami?' must be a Hash"
end
if args[:iface].to_s =~ /^lo/ # Linux loopback more or less. Need a switch for windows loopback, too.
- 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 whoami?
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.whoami?(args={})
unless args.kind_of? Hash
raise ArgumentError, "Argument to `whoami?' must be a Hash"
end
if args[:iface].to_s =~ /^lo/ # Linux loopback more or less. Need a switch for windows loopback, too.
Method arp
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def self.arp(target_ip,args={})
iface = args[:iface] || :eth0
args[:config] ||= whoami?(:iface => iface)
arp_pkt = PacketFu::ARPPacket.new(:flavor => (args[:flavor] || :none), :config => args[:config])
arp_pkt.eth_daddr = "ff:ff:ff:ff:ff:ff"
- 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 scan_ip
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def scan_ip(ip)
ret = []
@ports.each do |port|
Method default_int
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.default_int
ip = default_ip
NetworkInterface.interfaces.each do |interface|
NetworkInterface.addresses(interface).values.each do |addresses|
- 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"