lib/linux_admin/ssh.rb
Method execute_commands
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
def execute_commands(commands, agent_socket, stdin)
result = nil
args = {:verify_host_key => false, :number_of_password_prompts => 0}
if agent_socket
args.merge!(:forward_agent => true,
- 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 ssh_exec!
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def ssh_exec!(ssh, command, stdin)
stdout_data = ''
stderr_data = ''
exit_status = nil
exit_signal = nil
Method ssh_exec!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def ssh_exec!(ssh, command, stdin)
stdout_data = ''
stderr_data = ''
exit_status = nil
exit_signal = 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
Use args[:forward_agent] = true; args[:agent_socket_factory] = -> { UNIXSocket.open(agent_socket) }
instead of args.merge!(:forward_agent => true,
:agent_socket_factory => -> { UNIXSocket.open(agent_socket) })
. Open
Open
args.merge!(:forward_agent => true,
:agent_socket_factory => -> { UNIXSocket.open(agent_socket) })
- Read upRead up
- Exclude checks
This cop identifies places where Hash#merge!
can be replaced by
Hash#[]=
.
Example:
hash.merge!(a: 1)
hash.merge!({'key' => 'value'})
hash.merge!(a: 1, b: 2)