ManageIQ/manageiq-ui-classic

View on GitHub

Showing 2,015 of 18,390 total issues

Method condition_edit has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def condition_edit
    case params[:button]
    when "cancel"
      id = params[:id] || "new"
      return unless load_edit("condition_edit__#{id}")
Severity: Major
Found in app/controllers/condition_controller.rb - About 3 hrs to fix

Function GenericObjectForm has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

const GenericObjectForm = ({ recordId }) => {
  const [{ initialValues, isLoading, classOptions }, setState] = useState({ isLoading: !!recordId });
  const promise = useMemo(() => API.options('/api/generic_object_definitions/'), []);
  const submitLabel = !!recordId ? __('Save') : __('Add');

Severity: Minor
Found in app/javascript/components/generic-objects-form/index.jsx - About 3 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 center_toolbar_filename_report has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def center_toolbar_filename_report
    if x_active_tree == :db_tree
      node = x_node
      if %w[root xx-g].include?(node)
        return nil
Severity: Minor
Found in app/helpers/application_helper/toolbar_chooser.rb - About 3 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 prov_req_submit has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def prov_req_submit
    id = session[:edit][:req_id] || "new"
    return unless load_edit("prov_edit__#{id}", "show_list")

    @edit[:new][:schedule_time] = @edit[:new][:schedule_time].in_time_zone("Etc/UTC") if @edit[:new][:schedule_time]
Severity: Minor
Found in app/controllers/application_controller/miq_request_methods.rb - About 3 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 exp_commit_field has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def exp_commit_field(exp)
    @edit[@expkey][:exp_value] ||= ''
    if @edit[@expkey][:exp_field].nil?
      add_flash(_("A field must be chosen to commit this expression element"), :error)
    elsif @edit[@expkey][:exp_value] != :user_input &&
Severity: Minor
Found in app/controllers/application_controller/filter.rb - About 3 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 ab_button_save has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def ab_button_save
    assert_privileges("ab_button_edit")
    @resolve = session[:resolve]
    attrs = {}
    @sb[:active_tab] = "ab_options_tab"
Severity: Minor
Found in app/controllers/application_controller/buttons.rb - About 3 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 forest_accept has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def forest_accept
    assert_privileges("ops_settings")

    forest_get_form_vars
    no_changes = true
Severity: Minor
Found in app/controllers/ops_controller/settings.rb - About 3 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 get_global_session_data has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def get_global_session_data
    # Set the current userid in the User class for this thread for models to use
    User.current_user = current_user
    # if session group for user != database group for the user then ensure it is a valid group
    if current_user.try(:current_group_id_changed?) && !current_user.miq_groups.include?(current_group)
Severity: Minor
Found in app/controllers/application_controller.rb - About 3 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 get_all_reps has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def get_all_reps(nodeid = nil)
    # set nodeid from @sb, incase sort was pressed
    nodeid = x_active_tree == :reports_tree ? x_node.split('-').last : x_node.split('-').last.split('_')[0] if nodeid.nil?
    @sb[:miq_report_id] = nodeid
    @record = @miq_report = MiqReport.for_user(current_user).find(@sb[:miq_report_id])
Severity: Minor
Found in app/controllers/report_controller/reports.rb - About 3 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 widget_buttons has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def widget_buttons
    buttons = []
    if role_allows?(:feature => "dashboard_add")
      unless @sb[:dashboards][@sb[:active_db]][:locked]
        buttons.push(:id         => "w_#{@widget.id}_close",
Severity: Minor
Found in app/presenters/widget_presenter.rb - About 3 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 render_listnav_filename has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def render_listnav_filename
      common_layouts = %w[
        physical_storage
        auth_key_pair_cloud
        placement_group
Severity: Major
Found in app/helpers/application_helper/listnav.rb - About 3 hrs to fix

Method prov_set_form_vars has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def prov_set_form_vars(req = nil)
    @edit ||= {}
    session[:prov_options]      = @options = nil  # Clearing out options that were set on show screen
    @edit[:req_id]              = req.try(:id)    # Save existing request record id, if passed in
    @edit[:key]                 = "prov_edit__#{@edit[:req_id] || "new"}"
Severity: Major
Found in app/controllers/application_controller/miq_request_methods.rb - About 3 hrs to fix

Method update_from_exp_tree has 80 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def update_from_exp_tree(exp)
      exp.delete(:token)
      key = exp.keys.first
      if exp[key]['field']
        typ = 'field'
Severity: Major
Found in app/controllers/application_controller/filter/expression.rb - About 3 hrs to fix

Class HostController has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

class HostController < 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/host_controller.rb - About 3 hrs to fix

Class DefaultMenu has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

  class DefaultMenu
    class << self
      def default_menu
        [
          # user, group switcher & find are NOT part of the menu
Severity: Minor
Found in app/presenters/menu/default_menu.rb - About 3 hrs to fix

Function basicInformationTabSchema has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const basicInformationTabSchema = (availableCatalogs, tenantTree, roleAllows, zones, currencies) => {
  const schema = {
    component: componentTypes.TAB_ITEM,
    id: 'basic-information-tab',
    name: 'basic-information-tab',

Function basicInformationTabSchema has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const basicInformationTabSchema = (availableCatalogs, tenantTree, roleAllows, zones, currencies) => {
  const schema = {
    component: componentTypes.TAB_ITEM,
    id: 'basic-information-tab',
    name: 'basic-information-tab',

Method title_from_layout has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def title_from_layout(layout)
      # no layout, leave title alone
      return nil if layout.blank?

      case layout
Severity: Major
Found in app/helpers/application_helper/title.rb - About 3 hrs to fix

Method build_search_filter_from_params has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def build_search_filter_from_params(schedule, filter_type, value, other_value)
    resource_type = schedule.resource_type
    check_compliance = schedule&.sched_action&.dig(:method) == "check_compliance"
    filter_resource_type = if check_compliance
                             if resource_type == "ContainerImage"
Severity: Major
Found in app/controllers/ops_controller/settings/schedules.rb - About 3 hrs to fix

Method replace_right_cell has 78 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def replace_right_cell(options = {})
    nodetype, replace_trees = options.values_at(:nodetype, :replace_trees)
    replace_trees = @replace_trees if @replace_trees # get_node_info might set this
    # FIXME

Severity: Major
Found in app/controllers/pxe_controller.rb - About 3 hrs to fix
Severity
Category
Status
Source
Language