ManageIQ/manageiq-ui-classic

View on GitHub

Showing 2,015 of 18,390 total issues

Method db_get_form_vars has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def db_get_form_vars
    @in_a_form = true
    @dashboard = @edit[:db_id] ? MiqWidgetSet.find(@edit[:db_id]) : MiqWidgetSet.new
    if %w[up down].include?(params[:button])
      db_move_cols_up if params[:button] == "up"
Severity: Minor
Found in app/controllers/report_controller/dashboards.rb - About 2 hrs 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 alert_build_pulldowns has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def alert_build_pulldowns
    @sb[:alert] ||= {}

    # :event_types
    unless @sb[:alert][:events] # Only create this once
Severity: Minor
Found in app/controllers/miq_alert_controller.rb - About 2 hrs 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 validate_user has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_user(user, task_id = nil, request = nil, authenticate_options = {})
    if task_id.present?
      validate_user_collect_task(user, task_id)
    else # First time thru, kick off authenticate task
      validation = validate_user_kick_off_task(user, request, authenticate_options)
Severity: Minor
Found in app/services/user_validation_service.rb - About 2 hrs 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 heatmaps_data has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def heatmaps_data(metrics)
    node_cpu_usage = []
    node_memory_usage = []

    metrics.each do |m|
Severity: Minor
Found in app/services/container_dashboard_service.rb - About 2 hrs 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 getConfigInfo has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  var getConfigInfo = function(configData) {
    vm.catalogItemModel.provisioning_repository_id = configData.provision.repository_id;
    vm.catalogItemModel.provisioning_playbook_id = configData.provision.playbook_id;
    vm.catalogItemModel.provisioning_machine_credential_id = configData.provision.credential_id;
    vm.catalogItemModel.provisioning_network_credential_id = configData.provision.network_credential_id;

Method workflow_instance_from_vars has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def workflow_instance_from_vars(req)
    options         = {}
    pre_prov_values = nil
    if %w[miq_template service_template vm].include?(@edit[:org_controller])
      if params[:prov_type] && !req # only do this new requests
Severity: Major
Found in app/controllers/application_controller/miq_request_methods.rb - About 2 hrs to fix

Method gfv_key_style has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def gfv_key_style(key, value)
    parm, f_idx, s_idx = key.split("_") # Get the parm type, field index, and style index
    f_idx = f_idx.to_i
    s_idx = s_idx.to_i
    f = @edit[:new][:field_order][f_idx] # Get the field element
Severity: Major
Found in app/controllers/report_controller/reports/editor.rb - About 2 hrs to fix

Function containerNodesData has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const containerNodesData = () => {
  const columns = [
    { is_narrow: true, header_text: '' },
    {
      text: 'Name', sort: 'str', col_idx: 0, align: 'left', header_text: 'Name',
Severity: Major
Found in app/javascript/spec/miq-data-table/data.js - About 2 hrs to fix

Method perf_chart_chooser has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def perf_chart_chooser
    assert_privileges("perf_reload")
    @record = identify_tl_or_perf_record
    @perf_record = @record.kind_of?(MiqServer) ? @record.vm : @record # Use related server vm record

Severity: Major
Found in app/controllers/application_controller/performance.rb - About 2 hrs to fix

Method settings_replace_right_cell has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def settings_replace_right_cell(nodetype, presenter)
    case nodetype
    when "ze" # zone edit
      # when editing zone in settings tree
      if @zone.id.blank?
Severity: Major
Found in app/controllers/ops_controller.rb - About 2 hrs to fix

Method gfv_sort has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def gfv_sort
    @edit[:new][:order] = params[:sort_order] if params[:sort_order]
    if params[:sort_group] # If grouping changed,
      @edit[:new][:group] = params[:sort_group]
      @refresh_div = "sort_div" # Resend the sort tab
Severity: Major
Found in app/controllers/report_controller/reports/editor.rb - About 2 hrs to fix

File miq-component.spec.js has 414 lines of code (exceeds 400 allowed). Consider refactoring.
Open

import {
  getDefinition,
  sanitizeAndFreezeInstanceId,
  validateInstance,
  define,
Severity: Minor
Found in app/javascript/spec/miq-component/miq-component.spec.js - About 2 hrs to fix

Class MiqActionController has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class MiqActionController < ApplicationController
  before_action :check_privileges
  before_action :get_session_data
  after_action :cleanup_action
  after_action :set_session_data
Severity: Minor
Found in app/controllers/miq_action_controller.rb - About 2 hrs to fix

Class AnsibleRepositoryController has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class AnsibleRepositoryController < ApplicationController
  before_action :check_privileges
  before_action :get_session_data

  after_action :cleanup_action
Severity: Minor
Found in app/controllers/ansible_repository_controller.rb - About 2 hrs to fix

Method display_methods has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def display_methods
        %w[
          availability_zones
          cloud_databases
          cloud_networks
Severity: Major
Found in app/controllers/mixins/ems_common.rb - About 2 hrs to fix

Method authenticate has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def authenticate
    @layout = "dashboard"

    unless params[:task_id] # First time thru, check for buttons pressed
      # Handle More and Back buttons (for changing password)
Severity: Major
Found in app/controllers/dashboard_controller.rb - About 2 hrs to fix

Method miq_report_edit has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def miq_report_edit
    assert_privileges(params[:id] || (@edit && @edit[:rpt_id]) ? "miq_report_edit" : "miq_report_new")
    case params[:button]
    when "cancel"
      if @edit[:rpt_id]
Severity: Major
Found in app/controllers/report_controller/reports/editor.rb - About 2 hrs to fix

Method schedule_edit has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def schedule_edit
    assert_privileges("miq_report_schedule_edit")
    case params[:button]
    when "cancel"
      @schedule = MiqSchedule.find(session[:edit][:sched_id]) if session[:edit] && session[:edit][:sched_id]
Severity: Major
Found in app/controllers/report_controller/schedules.rb - About 2 hrs to fix

Function link has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    link: function(scope, _elem, attrs, ctrl) {
      scope.$watch(attrs.ngModel, function() {
        if (ctrl.viewValue !== undefined) {
          setSomePeriodCheckedValidity(ctrl, attrs);
        }
Severity: Major
Found in app/javascript/oldjs/directives/configuration/min_time_check.js - About 2 hrs to fix

Function createSchema has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const createSchema = (newRecord, showUseConfig, ancestry, itemId) => {
  let fields = [{
    component: componentTypes.TEXT_FIELD,
    id: 'name',
    name: 'name',
Severity: Major
Found in app/javascript/components/ops-tenant-form/ops-tenant-form.schema.js - About 2 hrs to fix
Severity
Category
Status
Source
Language