ManageIQ/manageiq-ui-classic

View on GitHub

Showing 2,015 of 18,390 total issues

Method reconfigure_form_data has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def reconfigure_form_data(vm = @reconfigitems.first)
    {
      :recordId  => @reconfigitems.collect(&:id),
      :requestId => @request_id || 'new',
      :roles     => {
Severity: Minor
Found in app/helpers/vm_infra_helper.rb - About 1 hr to fix

Method perf_gen_tag_data_after_wait has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def perf_gen_tag_data_after_wait
    miq_task = MiqTask.find(params[:task_id])       # Not first time, read the task record
    rpt = miq_task.miq_report_result.report_results # Grab the report object from the blob
    miq_task.destroy                                # Get rid of the task and results

Severity: Minor
Found in app/controllers/application_controller/performance.rb - About 1 hr to fix

Method show_taskbar_in_header? has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def show_taskbar_in_header?
    return false if @explorer
    return false if controller.action_name.end_with?("tagging_edit")

    hide_actions = %w[
Severity: Minor
Found in app/helpers/application_helper.rb - About 1 hr to fix

Method rate_summary has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def rate_summary(data, optional)
    rows = []
    data.to_a.sort_by { |rd| [rd.chargeable_field[:group].downcase, rd.chargeable_field[:description].downcase, rd[:sub_metric].to_s.downcase] }.each_with_index do |detail, detail_index|
      cells = []
      tiers = detail.chargeback_tiers.order(:start)
Severity: Minor
Found in app/helpers/chargeback_rate_helper.rb - About 1 hr to fix

Method at_tree_select has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def at_tree_select(edit_key)
    id = parse_nodetype_and_id(params[:id]).last
    if params[:id].start_with?("aei-")
      record = MiqAeInstance.find_by(:id => id)
      @edit[:automate_tree_selected_path] = record.fqname
Severity: Minor
Found in app/helpers/automate_tree_helper.rb - About 1 hr to fix

Method build_tags_for_provisioning has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def build_tags_for_provisioning(wf, vm_tags, _edit_mode)
    # for some reason @tags is set in wf, and it is changed by map bellow which causes bugs
    wf.instance_variable_set(:@tags, nil)
    tags = wf.allowed_tags.map do |cat|
      {
Severity: Minor
Found in app/controllers/application_controller/miq_request_methods.rb - About 1 hr to fix

Method resolve_button_throw has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def resolve_button_throw
    if valid_resolve_object?
      add_flash(_("Automation Simulation has been run"))
      @sb[:name] = @resolve[:new][:instance_name].presence || @resolve[:new][:other_name]
      @sb[:attrs] = {}
Severity: Minor
Found in app/controllers/application_controller/automate.rb - About 1 hr to fix

Method build_download_rpt has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def build_download_rpt(cols, csv, typ)
    if typ.nil? || typ == "all"
      if csv # If generating CSV, remove * from data
        cols.each_with_index do |c, i|
          if c.to_s.starts_with?("* ")
Severity: Minor
Found in app/controllers/application_controller/compare.rb - About 1 hr to fix

Method adv_search_build has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def adv_search_build(model)
    # Restore @edit hash if it's saved in @settings
    @expkey = :expression # Reset to use default expression key
    if session.fetch_path(:adv_search, model.to_s) && %w[tag service_tag].exclude?(@sb[:action])
      adv_search_model = session[:adv_search][model.to_s]
Severity: Minor
Found in app/controllers/application_controller/advanced_search.rb - About 1 hr to fix

Method retrieve_git_datastore has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def retrieve_git_datastore
    assert_privileges('miq_ae_class_import_export')
    git_url = params[:git_url]

    if git_url.blank?
Severity: Minor
Found in app/controllers/miq_ae_tools_controller.rb - About 1 hr to fix

Method policy_field_changed has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def policy_field_changed
    return unless load_edit("miq_policy_edit__#{params[:id]}")

    case @edit[:typ]
    when "events"
Severity: Minor
Found in app/controllers/miq_policy_controller/policies.rb - About 1 hr to fix

Method ap_set_record_vars has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def ap_set_record_vars(mems, scanitemset)
    unless mems.empty?
      mems_to_delete = []
      mems.each { |m| mems_to_delete.push(m) }
      ap_deletescanitems(mems_to_delete)
Severity: Minor
Found in app/controllers/ops_controller/settings/analysis_profiles.rb - About 1 hr to fix

Method delete_subnets has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def delete_subnets
    assert_privileges("cloud_subnet_delete")
    subnets = find_records_with_rbac(CloudSubnet, checked_or_params)

    subnets_to_delete = []
Severity: Minor
Found in app/controllers/cloud_subnet_controller.rb - About 1 hr to fix

Method button has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def button
    case params[:pressed]
    when "cloud_tenant_new"
      javascript_redirect(:action => "new")
    when "cloud_tenant_edit"
Severity: Minor
Found in app/controllers/cloud_tenant_controller.rb - About 1 hr to fix

Function miqJqueryRequest has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

window.miqJqueryRequest = function(url, options) {
  if ((ManageIQ.observe.processing || ManageIQ.observe.queue.length) && (!options || !options.observe)) {
    console.debug('Postponing miqJqueryRequest - waiting for the observe queue to empty first');

    return new Promise((resolve, reject) => {
Severity: Minor
Found in app/javascript/oldjs/miq_application.js - About 1 hr 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

Function selectListElement has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

var selectListElement = function(scope, timeout, ctrl, refresh) {
  timeout(function() {
    if (refresh) {
      if (scope[scope['form_' + ctrl.$name + '_ngHide']] === true) {
        angular.element(scope['form_' + ctrl.$name]).selectpicker('hide');

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

Function controller has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  controller: function() {
    this.buttonClicked = function(event) {
      if (this.enabled) {
        this.onClick();
      }
Severity: Minor
Found in app/javascript/oldjs/components/miq-button.js - About 1 hr 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

Function miqValidateButtons has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

window.miqValidateButtons = function(h_or_s, prefix) {
  const buttonPrefix = prefix || '';
  const buttonsOnId = `${buttonPrefix}validate_buttons_on`;
  const buttonsOffId = `${buttonPrefix}validate_buttons_off`;

Severity: Minor
Found in app/javascript/oldjs/miq_application.js - About 1 hr 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

Function load_c3_charts has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

window.load_c3_charts = function() {
  for (var set in ManageIQ.charts.chartData) {
    for (var i = 0; i < ManageIQ.charts.chartData[set].length; i++) {
      var chart_id = 'miq_chart_' + set + '_' + i.toString();
      var data = ManageIQ.charts.chartData[set][i];
Severity: Minor
Found in app/javascript/oldjs/miq_c3.js - About 1 hr 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

Function miqOnLoad has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

window.miqOnLoad = function() {
  // controller to be used in url in miqDropComplete method
  ManageIQ.widget.dashboardUrl = 'dashboard/widget_dd_done';

  // Initialize the dashboard column sortables
Severity: Minor
Found in app/javascript/oldjs/miq_application.js - About 1 hr 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