ManageIQ/manageiq-ui-classic

View on GitHub

Showing 18,390 of 18,390 total issues

Avoid deeply nested control flow statements.
Open

                  next if k == :token                  # Skip the :token key
Severity: Major
Found in app/controllers/application_controller/filter.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

              if result[:request].nil?
                dialog_replace_right_cell
              else
                flash_to_session
                javascript_redirect(:controller => 'miq_request', :action => 'show_list')
Severity: Major
Found in app/controllers/application_controller/dialog_runner.rb - About 45 mins to fix

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

  def build_listnav_search_list(db)
    @settings[:default_search] = current_user.settings[:default_search] # Get the user's default search settings again, incase default search was deleted
    default_search_db = settings(:default_search, db.to_sym).to_s
    if default_search_db.present? && default_search_db.to_i != 0 && MiqSearch.exists?(default_search_db)
      @default_search = MiqSearch.find(default_search_db)
Severity: Minor
Found in app/controllers/application_controller/filter.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

        @sb[:vm_os] = VmOrTemplate.find(@edit.fetch_path(:new, :src_vm_id, 0)).platform if @edit.fetch_path(:new, :src_vm_id, 0)
Severity: Major
Found in app/controllers/application_controller/miq_request_methods.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            elsif evm_object_class == :Vm
              if params[key] == "__VM__NONE__" # Added this to deselect datastore in grid
                @edit[:new][f.to_sym] = [nil, nil] # Save [value, description]
              elsif v.id.to_i == val.to_i
                @edit[:new][f.to_sym] = [val, v.name] # Save [value, description]
Severity: Major
Found in app/controllers/application_controller/miq_request_methods.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

          if @edit[:new][ppid].zero? # Remove if new count is zero
            pp.remove_from(session[:pol_items], session[:pol_db])
            AuditEvent.success(protect_audit(pp, "remove_from", session[:pol_db], session[:pol_items]))
          else # else add
            pp.add_to(session[:pol_items], session[:pol_db])
Severity: Major
Found in app/controllers/application_controller/policy_support.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

              elsif params[key] == "__DS__NONE__" # Added this to deselect datastore in grid
                @edit[:new][f.to_sym] = [] # Save [value, description]
              elsif v.id.to_i == val.to_i
                if @edit[:new][f.to_sym].include?(val)
                  @edit[:new][f.to_sym].delete_if { |x| x == val }
Severity: Major
Found in app/controllers/application_controller/miq_request_methods.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if params[key] == ""
              @edit[:new][f.to_sym] = [nil]
            else
              @edit[:new][f.to_sym] = []
              params[key].split(",").each { |v| @edit[:new][f.to_sym].push(v) }
Severity: Major
Found in app/controllers/application_controller/miq_request_methods.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                if params[key] == "__DS__NONE__" # Added this to deselect datastore in grid
                  @edit[:new][f.to_sym] = [nil, nil] # Save [value, description]
                elsif v.id.to_i == val.to_i
                  @edit[:new][f.to_sym] = [val, v.name] # Save [value, description]
                end
Severity: Major
Found in app/controllers/application_controller/miq_request_methods.rb - About 45 mins to fix

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

    def self.from_options(options)
      additional_options = new
      additional_options.named_scope = options[:named_scope]
      additional_options.gtl_dbname = options[:gtl_dbname]
      additional_options.with_model(options[:model]) if options[:model]
Severity: Minor
Found in app/controllers/application_controller/report_data_additional_options.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 drift_build_record_rows has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def drift_build_record_rows(view, section, records, fields)
    records.each_with_index do |record, ridx|
      drift_add_record(view, section, record, ridx)
      unless drift_delete_row
        @rows.pop
Severity: Minor
Found in app/controllers/application_controller/compare.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 valid_active_node has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def valid_active_node(treenodeid)
    modelname, rec_id, nodetype = TreeBuilder.extract_node_model_and_id(treenodeid)
    return treenodeid if ["root", ""].include?(nodetype) # incase node is root or doesn't have a prefix
    raise _("No Class found for explorer tree node id '%{number}'") % {:number => treenodeid} if modelname.nil?

Severity: Minor
Found in app/controllers/application_controller/explorer.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 scan_histories has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def scan_histories
    @vm = @record = identify_record(params[:id], VmOrTemplate)
    @explorer = true if request.xml_http_request? # Ajax request means in explorer
    @scan_history = ScanHistory.find_by(:vm_or_template_id => @record.id)
    if @scan_history.nil?
Severity: Minor
Found in app/controllers/vm_common.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

        process_show_list(options) if show_list
Severity: Major
Found in app/controllers/vm_common.rb - About 45 mins to fix

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

  def adv_search_load_choice
    @edit = session[:edit]
    if params[:chosen_search]
      @edit[@expkey][:exp_chosen_report] = nil
      if params[:chosen_search] == "0"
Severity: Minor
Found in app/controllers/application_controller/advanced_search.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 group_new_edit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def group_new_edit(typ)
    @record = @custom_button_set = typ == "new" ? CustomButtonSet.new : CustomButtonSet.find(params[:id])
    if typ == "edit" && x_node.split('_').last == "ub"
      add_flash(_("'Unassigned Button Group' can not be edited"), :error)
      get_node_info
Severity: Minor
Found in app/controllers/application_controller/buttons.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 cancel_task has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def cancel_task
    assert_privileges("miq_task_canceljob")
    task_id = find_checked_items
    task = MiqTask.find_by(:id => task_id)
    message = if task.nil?
Severity: Minor
Found in app/controllers/miq_task_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 initiate_wait_for_task has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def initiate_wait_for_task(options = {})
    task_id = options[:task_id]
    session[:async] ||= {}
    session[:async][:interval] ||= 1000 # Default interval to 1 second
    session[:async][:params] ||= {}
Severity: Minor
Found in app/controllers/application_controller/wait_for_task.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 exp_model != '_display_filter_' &&
                 MiqExpression::Field.parse(exp_field).plural? &&
                 !%i[date datetime].include?(chosen_field_col_type) &&
                 chosen_field_col_type.object_id != :integer.object_id
                self.exp_key = 'CONTAINS' # CONTAINS is valid only for plural tables
Severity: Major
Found in app/controllers/application_controller/filter/expression.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            @resolve[:new][:attrs].push(attr) unless @resolve[:new][:attrs].include?(attr)
Severity: Major
Found in app/controllers/application_controller/buttons.rb - About 45 mins to fix
Severity
Category
Status
Source
Language