ManageIQ/manageiq-ui-classic

View on GitHub

Showing 2,015 of 18,390 total issues

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

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

    def rewind(direction)
      case direction
      when 'undo'
        if idx.positive?
          self.idx -= 1
Severity: Minor
Found in app/controllers/application_controller/filter/expression_edit_history.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 adv_search_button has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def adv_search_button
    @edit = session[:edit]
    @view = session[:view]

    # setting default to false
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

Avoid deeply nested control flow statements.
Open

              self.exp_ckey = nil unless MiqExpression.get_col_operators(exp_cfield).include?(exp_ckey)
Severity: Major
Found in app/controllers/application_controller/filter/expression.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

        @right_cell_text = if model
                             _("Archived %{models}") % {:models => ui_lookup(:models => model)}
                           else
                             _("Archived VMs & Templates")
                           end
Severity: Major
Found in app/controllers/vm_common.rb - About 45 mins to fix

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

  def replace_right_cell(options = {})
    nodetype, replace_trees = options.values_at(:nodetype, :replace_trees)
    if params[:pressed] == "custom_button"
      presenter = set_custom_button_dialog_presenter(options)
      render :json => presenter.for_render
Severity: Minor
Found in app/controllers/ops_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 valid_resolve_object? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def valid_resolve_object?
    add_flash(_("Starting Class must be selected"), :error) if @resolve[:new][:starting_object].blank?
    if @resolve[:new][:instance_name].blank? && @resolve[:new][:other_name].blank?
      add_flash(_("Starting Process is required"), :error)
    end
Severity: Minor
Found in app/controllers/miq_ae_tools_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

              self.exp_key = nil unless MiqExpression.get_col_operators(:count).include?(exp_key)
Severity: Major
Found in app/controllers/application_controller/filter/expression.rb - About 45 mins to fix
Severity
Category
Status
Source
Language