modules/post/linux/gather/enum_network.rb
Method run
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def run
print_status("Running module against #{get_hostname} (#{session.session_host})")
user = execute('/usr/bin/whoami')
print_status("Module running as #{user}")
Method get_ssh_keys
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def get_ssh_keys
keys = []
# Look for .ssh folder, "~/" might not work everytime
vprint_status('Execute: /usr/bin/find / -maxdepth 3 -name .ssh')
- 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"