ManageIQ/manageiq-ui-classic

View on GitHub

Showing 2,015 of 18,390 total issues

Method selected_menu_consecutive? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def selected_menu_consecutive?
    first_idx = last_idx = 0
    @edit[:selected_reports].each_with_index do |nf, idx|
      first_idx = idx if nf == params[:selected_reports].first
      if nf == params[:selected_reports].last
Severity: Minor
Found in app/controllers/report_controller/menus.rb - About 35 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 condition_field_changed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def condition_field_changed
    return unless load_edit("condition_edit__#{params[:id]}")

    @condition = @edit[:condition_id] ? Condition.find(@edit[:condition_id]) : Condition.new

Severity: Minor
Found in app/controllers/condition_controller.rb - About 35 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 db_selected_consecutive? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def db_selected_consecutive?
    first_idx = last_idx = 0
    @edit[:new][:dashboard_order].each_with_index do |nf, idx|
      first_idx = idx if nf == params[:seq_fields].first
      if nf == params[:seq_fields].last
Severity: Minor
Found in app/controllers/report_controller/dashboards.rb - About 35 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_miq_server_kids has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def x_get_tree_miq_server_kids(parent, _count_only)
    parent.assigned_server_roles.sort_by { |asr| asr.server_role.description }.each_with_object([]) do |asr, objects|
      next if parent.kind_of?(MiqRegion) && !asr.server_role.regional_role? # Only regional roles under Region
      next if asr.server_role.name == "database_owner"
      objects.push(asr)
Severity: Minor
Found in app/presenters/tree_builder_roles_by_server.rb - About 35 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_hash_kids has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def x_get_tree_hash_kids(parent, count_only)
    nodes = parent[:nodes].map do |policy|
      icon = policy.towhat.safe_constantize.try(:decorate).try(:fonticon)
      mode = if policy.mode == "control"
               _("Control")
Severity: Minor
Found in app/presenters/tree_builder_protect.rb - About 35 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 count_only_or_objects has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def count_only_or_objects(count_only, objects, sort_by = nil)
    if count_only
      objects.respond_to?(:order) ? objects.except(:order).size : objects.size
    elsif sort_by.kind_of?(Proc)
      objects.sort_by(&sort_by)
Severity: Minor
Found in app/presenters/tree_builder.rb - About 35 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 section_for_item_id has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def section_for_item_id(item_id)
      found = nil
      @id_to_section.each do |_id, section|
        next unless section.contains_item_id?(item_id)

Severity: Minor
Found in app/presenters/menu/manager.rb - About 35 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 import_widgets has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def import_widgets(import_file_upload, widgets_to_import)
    number_imported_widgets = 0
    unless widgets_to_import.nil?
      widgets = YAML.load(import_file_upload.uploaded_content)

Severity: Minor
Found in app/services/widget_import_service.rb - About 35 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 active_node_set has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def active_node_set(tree_nodes)
    stack = [tree_nodes.last]
    while stack.any?
      node = stack.pop
      # If the node's text has an active suffix, return with it
Severity: Minor
Found in app/presenters/tree_builder_snapshots.rb - About 35 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_datacenter_kids has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def x_get_tree_datacenter_kids(parent, count_only)
    children = parent.folders.each_with_object([]) do |child, arr|
      next if !child.kind_of?(EmsFolder) || child.name == 'host'

      child.name == 'vm' ? arr.concat(child.folders_only) : arr.push(child)
Severity: Minor
Found in app/presenters/tree_builder_belongs_to_vat.rb - About 35 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 too many return statements within this function.
Open

  return cellValue;
Severity: Major
Found in app/javascript/components/miq-data-table/helper.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

    return `${value}.bytes`;
Severity: Major
Found in app/javascript/components/workers-form/helpers.jsx - About 30 mins to fix

Avoid too many return statements within this function.
Open

      if (hasToggle(keys)) return { ...content, component: cellToggle(data, id), cellClick: false };
Severity: Major
Found in app/javascript/components/miq-data-table/miq-table-cell.jsx - About 30 mins to fix

Avoid too many return statements within this function.
Open

      if (hasTextInput(keys)) return { ...content, component: cellTextInput(data, id), cellClick: false };
Severity: Major
Found in app/javascript/components/miq-data-table/miq-table-cell.jsx - About 30 mins to fix

Avoid too many return statements within this function.
Open

    return `${value} B`;
Severity: Major
Found in app/javascript/components/workers-form/helpers.jsx - About 30 mins to fix

Avoid too many return statements within this function.
Open

    return { ...content, component: cellText() };
Severity: Major
Found in app/javascript/components/miq-data-table/miq-table-cell.jsx - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return Number(sizeValue);
Severity: Major
Found in app/javascript/components/workers-form/helpers.jsx - About 30 mins to fix

Avoid too many return statements within this function.
Open

  return value
    .replace('.gigabytes', ' GB')
    .replace('.megabytes', ' MB')
    .replace('.kilobytes', ' KB')
    .replace('.bytes', ' B');
Severity: Major
Found in app/javascript/components/workers-form/helpers.jsx - About 30 mins to fix

Avoid too many return statements within this function.
Open

    return (
      <TableCard title={title} chartData={chartData} />
    );
Severity: Major
Found in app/javascript/components/container-projects/chart-card.jsx - About 30 mins to fix

Avoid too many return statements within this function.
Open

  return (
    <AreaChartCard title={title} textNumber={textNumber} textUnit={textUnit} textTitle={textTitle} chartData={chartData} options={options} />
  );
Severity: Major
Found in app/javascript/components/container-projects/chart-card.jsx - About 30 mins to fix
Severity
Category
Status
Source
Language