ManageIQ/manageiq-ui-classic

View on GitHub
app/helpers/ops_helper.rb

Summary

Maintainability
A
3 hrs
Test Coverage
F
42%

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({
Severity: Minor
Found in app/helpers/ops_helper.rb - About 1 hr to fix

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"}
Severity: Minor
Found in app/helpers/ops_helper.rb - About 1 hr to fix

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)]
Severity: Minor
Found in app/helpers/ops_helper.rb - About 45 mins to fix

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' : ''
Severity: Minor
Found in app/helpers/ops_helper.rb - About 25 mins to fix

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) }
Severity: Minor
Found in app/helpers/ops_helper.rb by rubocop

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)
Severity: Minor
Found in app/helpers/ops_helper.rb by rubocop

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

There are no issues that match your filters.

Category
Status