ManageIQ/manageiq-ui-classic

View on GitHub

Showing 2,015 of 18,390 total issues

Avoid deeply nested control flow statements.
Open

                  temp.push(el) unless temp.include?(el)
Severity: Major
Found in app/controllers/report_controller/menus.rb - About 45 mins to fix

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

  def ems_utilization
    used_cpu = Hash.new(0)
    used_mem = Hash.new(0)
    total_cpu = Hash.new(0)
    total_mem = Hash.new(0)
Severity: Minor
Found in app/services/ems_infra_dashboard_service.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 x_get_tree_roots has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def x_get_tree_roots
    nodes = []
    group = nil
    @data.master_list.each_slice(3) do |section, _records, _fields|
      if group.blank? || section[:group] != group
Severity: Minor
Found in app/presenters/tree_builder_sections.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 prune_folders_via_folders has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def prune_folders_via_folders(tree, allowed_folder_ids)
    has_sub_folders = false
    tree.select! do |object, children|
      has_sub_sub_folders = prune_folders_via_folders(children, allowed_folder_ids)

Severity: Minor
Found in app/presenters/tree_builder_vandt.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 fill_utilization has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def fill_utilization(m, time, used_cpu, used_mem, total_cpu, total_mem)
Severity: Minor
Found in app/services/container_service_mixin.rb - About 45 mins to fix

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

  def x_get_tree_pxe_server_kids(object, count_only)
    pxe_images = object.pxe_images
    win_images = object.windows_images
    if count_only
      open_node("xx-pxe_xx-#{object.id}")
Severity: Minor
Found in app/presenters/tree_builder_pxe_servers.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

Consider simplifying this complex logical expression.
Open

    if (isEdit) {
      http.get(`/miq_ae_customization/old_dialogs_edit_get/${dialogRecord.id}/`).then((recordValues) => {
        if (recordValues) {
          setData({ ...data, isLoading: false, initialValues: recordValues });
        }
Severity: Major
Found in app/javascript/components/miq-ae-customization/index.jsx - About 40 mins to fix

Consider simplifying this complex logical expression.
Open

      if item.leaf?
        # FIXME: remove @layout condition when every controller sets menu_section properly
        active = controller.menu_section_id(controller.params) || @layout.to_sym
        item.id.to_sym == active || item.id.to_sym == @layout.to_sym
      else
Severity: Major
Found in app/helpers/application_helper/navbar.rb - About 40 mins to fix

Consider simplifying this complex logical expression.
Open

    if (@lastaction != "show" || (@lastaction == "show" && @display != "main")) &&
       @record &&
       (@record.respond_to?('name') && !@record.name.nil?)
      return true
    else
Severity: Major
Found in app/helpers/application_helper.rb - About 40 mins to fix

Consider simplifying this complex logical expression.
Open

    if DRIFT_TIME_COLUMNS.include?(datum[0].to_s) && datum[1].kind_of?(Hash) &&
       datum[1].key?(:_value_) && datum[1][:_value_].present? &&
       datum[1][:_value_] != "" && datum[1][:_value_] != MiqCompare::EMPTY
      datum[1][:_value_] = format_timezone(datum[1][:_value_], Time.zone, "view")
    end
Severity: Major
Found in app/controllers/application_controller/compare.rb - About 40 mins to fix

Consider simplifying this complex logical expression.
Open

    if params[:chosen_value] || params[:chosen_regkey] || params[:chosen_regval] ||
       params[:chosen_cvalue || params[:chosen_suffix]] || params[:alias]
      render :update do |page|
        page << javascript_prologue
      end
Severity: Major
Found in app/controllers/application_controller/filter.rb - About 40 mins to fix

Consider simplifying this complex logical expression.
Open

      if hourly_date.present? &&
         (hourly_date.to_date < sdate.to_date || hourly_date.to_date > edate.to_date || # it is out of range
         (typ == 'Hourly' && time_profile && !time_profile_days.include?(hourly_date.to_date.wday))) # or out of profile
        self.hourly_date = nil
      end
Severity: Major
Found in app/controllers/application_controller/performance/options.rb - About 40 mins to fix

Consider simplifying this complex logical expression.
Open

    if datum[1].kind_of?(Hash) && datum[1].key?(:_value_) &&
       datum[1][:_value_].kind_of?(Time) && datum[1][:_value_].present? &&
       datum[1][:_value_] != "" && datum[1][:_value_] != MiqCompare::EMPTY
      datum[1][:_value_] = format_timezone(datum[1][:_value_], Time.zone, "view")
    end
Severity: Major
Found in app/controllers/application_controller/compare.rb - About 40 mins to fix

Consider simplifying this complex logical expression.
Open

      if params.key?(:instance_name) || params.key?(:starting_object) ||
         params.key?(:target_class) || params.key?(:target_id) ||
         params.key?(:other_name) || params.key?(:target_attr_name)
        unless params.key?(:other_name) || params.key?(:target_attr_name)
          page.replace("resolve_form_div", :partial => "resolve_form")
Severity: Major
Found in app/controllers/miq_ae_tools_controller.rb - About 40 mins to fix

Consider simplifying this complex logical expression.
Open

    if params[:user_name].blank? && params[:user_password].blank? &&
       request.headers["X-Remote-User"].blank? &&
       ::Settings.authentication.mode == "httpd" &&
       ::Settings.authentication.sso_enabled &&
       params[:action] == "authenticate"
Severity: Major
Found in app/controllers/dashboard_controller.rb - About 40 mins to fix

Consider simplifying this complex logical expression.
Open

    elsif record_showing || @in_a_form || @sb[:buttons_node] ||
          (@pages && (@items_per_page == ONE_MILLION || @pages[:items] == 0))
      if %w[button_edit group_edit group_reorder at_st_new st_new st_catalog_new st_catalog_edit copy_catalog].include?(action)
        presenter.hide(:toolbar).show(:paging_div)
        # incase it was hidden for summary screen, and incase there were no records on show_list
Severity: Major
Found in app/controllers/catalog_controller.rb - About 40 mins to fix

Consider simplifying this complex logical expression.
Open

      if !features? || options[:not_tree]
        # Append breadcrumb from @record item (eg "Openstack") when on some action page (not show, display)
        breadcrumbs.push(build_breadcrumbs_no_explorer(options[:record_info], options[:record_title])) if not_show_page? || options[:include_record]

        # Append tag and policy breadcrumb if they exist
Severity: Major
Found in app/controllers/mixins/breadcrumbs_mixin.rb - About 40 mins to fix

Function saveRecord has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  function saveRecord(apiURL, redirectURL, object, successMsg, action) {
Severity: Minor
Found in app/javascript/oldjs/services/post_service.js - About 35 mins to fix

Function createSchema has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

function createSchema(ems, cloudNetworkId, loadSchema, emptySchema, providerFields = []) {

Function adjustValidationStatus has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

var adjustValidationStatus = function(value, scope, ctrl, attrs, rootScope) {
Severity: Minor
Found in app/javascript/oldjs/directives/validation/reset_validation_status.js - About 35 mins to fix
Severity
Category
Status
Source
Language