ManageIQ/manageiq-ui-classic

View on GitHub

Showing 2,015 of 18,390 total issues

Method delete has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def delete
    # TODO: this will be unnecessary after `chargeback_rates_delete` gets renamed to `chargeback_rate_delete`
    assert_privileges("chargeback_rates_delete")
    rates = []
    if !params[:id] # showing a list
Severity: Minor
Found in app/controllers/chargeback_rate_controller.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 show_details has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def show_details(db, options = {})
      association = options[:association]
      scopes = options[:scopes]
      @showtype = "details"
      @display = "main"
Severity: Minor
Found in app/controllers/mixins/explorer_show.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

Avoid deeply nested control flow statements.
Open

              model, model_id, _ = TreeBuilder.extract_node_model_and_id(options[:x_node]) if options[:x_node]
Severity: Major
Found in app/controllers/mixins/breadcrumbs_mixin.rb - About 45 mins to fix

Method servicetemplate_edit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def servicetemplate_edit
    assert_privileges_for_servicetemplate_edit

    checked_id = find_checked_items.first || params[:id]
    @sb[:cached_waypoint_ids] = MiqAeClass.waypoint_ids_for_state_machines
Severity: Minor
Found in app/controllers/catalog_controller.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

Avoid deeply nested control flow statements.
Open

      if @custom_button.uri_attributes
        default_attributes = if @custom_button[:options].try(:[], :button_type)
                               %w[request service_template_name hosts]
                             else
                               %w[request]
Severity: Major
Found in app/controllers/miq_ae_customization_controller/custom_buttons.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

      if @custom_button.visibility && @custom_button.visibility[:roles] && @custom_button.visibility[:roles][0] != "_ALL_"
        MiqUserRole.all.sort_by(&:name).each do |r|
          @sb[:user_roles].push(r.name) if @custom_button.visibility[:roles].include?(r.name)
        end
      end
Severity: Major
Found in app/controllers/miq_ae_customization_controller/custom_buttons.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

      @resolve[:new][:target_class] = if @nodetype[0].starts_with?("-ub-")
                                        # selected button is under unassigned folder
                                        @nodetype[0].sub('-ub-', '')
                                      else
                                        @nodetype[1]
Severity: Major
Found in app/controllers/miq_ae_customization_controller/custom_buttons.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

      @enablement_expression_table = exp_build_table(@custom_button.enablement_expression.exp) if @custom_button.enablement_expression.kind_of?(MiqExpression)
Severity: Major
Found in app/controllers/miq_ae_customization_controller/custom_buttons.rb - About 45 mins to fix

Method verify_hosts_for_scaledown has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def verify_hosts_for_scaledown(hosts)
    has_invalid_nodes = false
    error_return_message = _("Not all hosts can be removed from the deployment.")

    hosts.each do |host|
Severity: Minor
Found in app/controllers/ems_infra_controller.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 vm_chargeback has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def vm_chargeback
      @sb[:action] ||= 'chargeback'
      @vm = @record = identify_record(params[:id], VmOrTemplate)
      unless @record.has_perf_data?
        add_flash(_('No Capacity & Utilization data has been collected for this VM'))
Severity: Minor
Found in app/controllers/mixins/chargeback_preview_mixin.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

Avoid deeply nested control flow statements.
Open

              node = TreeNode.new(record) if record
Severity: Major
Found in app/controllers/mixins/breadcrumbs_mixin.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

          @sb[:buttons].push(button) unless @sb[:buttons].include?(button)
Severity: Major
Found in app/controllers/miq_ae_customization_controller/custom_buttons.rb - About 45 mins to fix

Method get_form_vars has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def get_form_vars
    @edit[:new][:cbshow_typ] = params[:cbshow_typ] if params[:cbshow_typ]
    @edit[:new][:cbtag_cat] = nil if params[:cbshow_typ] # Reset categories pull down if assign to selection is changed
    @edit[:new][:cbtag_cat] = params[:cbtag_cat].to_s if params[:cbtag_cat]
    @edit[:new][:cblabel_key] = nil if params[:cbshow_typ]
Severity: Minor
Found in app/controllers/chargeback_assignment_controller.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

Avoid deeply nested control flow statements.
Open

            if details
              add_flash(_("Re-checking Authentication status for this %{controller_name} was not successful: %{details}") %
                            {:controller_name => ui_lookup(:table => controller_name), :details => details}, :error)
            end
Severity: Major
Found in app/controllers/mixins/ems_common.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

          next if b.custom_button_sets.present?
Severity: Major
Found in app/controllers/miq_ae_customization_controller/custom_buttons.rb - About 45 mins to fix

Method scaledown has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def scaledown
    assert_privileges("ems_infra_scale")
    redirect_to(ems_infra_path(params[:id])) if params[:cancel]

    # Hiding the toolbars
Severity: Minor
Found in app/controllers/ems_infra_controller.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

Avoid deeply nested control flow statements.
Open

              next unless details
Severity: Major
Found in app/controllers/mixins/ems_common.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

      @sb[:dialog_label] = dialog_id ? Dialog.find(dialog_id).label : ""
Severity: Major
Found in app/controllers/miq_ae_customization_controller/custom_buttons.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

          next if bidx != b.id
Severity: Major
Found in app/controllers/miq_ae_customization_controller/custom_buttons.rb - About 45 mins to fix

Method widget_add has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def widget_add
    assert_privileges("dashboard_add")
    if params[:widget] # Make sure we got a widget in
      w = params[:widget].to_i
      if @sb[:dashboards][@sb[:active_db]][:col2].length < @sb[:dashboards][@sb[:active_db]][:col1].length
Severity: Minor
Found in app/controllers/dashboard_controller.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

Severity
Category
Status
Source
Language