app/controllers/mixins/actions/host_actions/misc.rb
Method host_button_operation
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
def host_button_operation(method, display_name)
hosts = find_records_with_rbac(Host, checked_or_params).ids
process_hosts(hosts, method, display_name)
# Either a list or coming from a different controller (eg from ems screen, go to its hosts)
- Read upRead up
- Create a ticketCreate a ticket
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 process_hosts_maintenance
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def process_hosts_maintenance(hosts, display_name)
each_host(hosts, display_name) do |host|
if host.maintenance
if host.supports?(:unset_node_maintenance)
host.unset_node_maintenance_queue(session[:userid])
- Read upRead up
- Create a ticketCreate a ticket
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"