app/helpers/dashboard_helper.rb
Method get_overview
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def get_overview(report, options = {})
options[:origin] = nil if options[:origin] == 'All'
state_labels = {
active_hosts_ok_enabled: _('Active'),
Method auto_refresh_button
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def auto_refresh_button(options = {})
on = options[:defaults_to] ? "on" : "off"
if params[:auto_refresh].present?
on = (params[:auto_refresh] == "0") ? "off" : "on"
end
- 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 search_filter_with_origin
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def search_filter_with_origin(filter, origin, within_interval = false, ignore_interval = false)
interval_setting = report_origin_interval_setting(origin)
additional_filters = []
additional_filters << "origin = #{origin}" if origin
additional_filters << "last_report #{within_interval ? '<' : '>'} \"#{interval_setting} minutes ago\"" if out_of_sync_enabled?(origin) && !ignore_interval
- 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"