Method miq_summary_rbac_details
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def miq_summary_rbac_details(users, groups, roles, tenants)
data = {:title => _("Access control"), :mode => "miq_access_control"}
rows = []
if role_allows?(:feature => "rbac_user_view", :any => true)
rows.push({
- Create a ticketCreate a ticket
Method select_by_servers
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def select_by_servers(record)
if record.instance_of?(MiqServer)
select_server_details(record)
else
data = {:mode => "selected_server_role_details"}
- 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 select_by_roles
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def select_by_roles(record)
if record.instance_of?(ServerRole)
data = {:mode => "selected_server_by_role_details"}
rows = [{:cells => [{:icon => "ff ff-user-role settings-icn"}]},
row_data(_('Role'), record.description)]
- 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 hide_button
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def hide_button(button, opt)
if opt == "on"
button ? '' : 'display:none'
else
button ? 'display:none' : ''
- 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
Avoid immutable Array literals in loops. It is better to extract it into a local variable or a constant. Open
tree_keys.any? { |t_key| %w[msc sis z l ld lr].include?(t_key) }
- Create a ticketCreate a ticket
- Exclude checks
Method OpsHelper#row_data
is defined at both app/helpers/ops_helper.rb:18 and app/helpers/ops_helper.rb:253. Open
def row_data(label, value)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for duplicated instance (or singleton) method definitions.
Example:
# bad
def foo
1
end
def foo
2
end
Example:
# bad
def foo
1
end
alias foo bar
Example:
# good
def foo
1
end
def bar
2
end
Example:
# good
def foo
1
end
alias bar foo