ManageIQ/manageiq-ui-classic

View on GitHub

Showing 18,382 of 18,382 total issues

Method set_form_vars has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

  def set_form_vars
    @edit = {}
    @edit[:rpt_id] = @rpt.id # Save a record id to use it later to look a record
    @edit[:rpt_title] = @rpt.title
    @edit[:rpt_name] = @rpt.name
Severity: Minor
Found in app/controllers/report_controller/reports/editor.rb - About 1 day 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_valid_record? has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

  def alert_valid_record?(alert)
    if alert.expression.nil?
      add_flash(_("A valid expression must be present"), :error)
    end
    unless display_driving_event?
Severity: Minor
Found in app/controllers/miq_alert_controller.rb - About 1 day 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 createSchema has 245 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const createSchema = (state, setState, ems, initialValues, storageId, setStorageId) => {
  let emsId = state.ems_id;
  if (initialValues && initialValues.ems_id) {
    emsId = initialValues.ems_id;
  }

Method perf_gen_charts has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

  def perf_gen_charts(rpt, perf_options, parent = false)
    model_title = parent ? "Parent-#{perf_options[:parent]}" : perf_options[:model]
    charts = []
    chart_data = []
    case perf_options[:typ]
Severity: Minor
Found in app/controllers/application_controller/performance.rb - About 1 day 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 addSchema has 237 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const addSchema = (formValues) => {
  const basicOptions = generateBasicOptions();
  const rangeNine = generateRange(10);
  const rangeFour = generateRange(5);
  const rangeFive = generateRange(6);
Severity: Major
Found in app/javascript/components/workers-form/workers.schema.js - About 1 day to fix

Method workflow_instance_from_vars has a Cognitive Complexity of 60 (exceeds 5 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: Minor
Found in app/controllers/application_controller/miq_request_methods.rb - About 1 day 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  it('should call methods - singleValue is true', () => {
    const onTagCategoryChange = jest.fn();
    const onTagValueChange = jest.fn();
    const onSingleTagValueChange = jest.fn();
    const onTagDeleteClick = jest.fn();
Severity: Major
Found in app/javascript/tagging/tests/tagging.test.js and 1 other location - About 1 day to fix
app/javascript/tagging/tests/tagging.test.js on lines 108..128

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 222.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  it('should call methods - singleValue is false', () => {
    const onTagCategoryChange = jest.fn();
    const onTagValueChange = jest.fn();
    const onSingleTagValueChange = jest.fn();
    const onTagDeleteClick = jest.fn();
Severity: Major
Found in app/javascript/tagging/tests/tagging.test.js and 1 other location - About 1 day to fix
app/javascript/tagging/tests/tagging.test.js on lines 130..150

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 222.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method show has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

  def show(id = nil)
    @flash_array = [] if params[:display] && params[:display] != "snapshot_info"
    @sb[:action] = params[:display]

    return if perfmenu_click?
Severity: Minor
Found in app/controllers/vm_common.rb - About 1 day 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 diagnostics_set_form_vars has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

  def diagnostics_set_form_vars
    active_node = x_node
    if active_node && active_node.split('-').first == "z"
      @record = @selected_server = Zone.find_by(:id => active_node.split('-').last)
      @sb[:selected_server_id] = @selected_server.id
Severity: Minor
Found in app/controllers/ops_controller/diagnostics.rb - About 1 day 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 set_global_session_data has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

  def set_global_session_data
    @sb ||= {}
    # Set all of the global variables used by most of the controllers
    session[:layout] = @layout
    session[:panels] = @panels
Severity: Minor
Found in app/controllers/application_controller.rb - About 1 day 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_set_form_vars has a Cognitive Complexity of 58 (exceeds 5 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: Minor
Found in app/controllers/application_controller/miq_request_methods.rb - About 1 day 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 form_method_field_changed has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

  def form_method_field_changed
    assert_privileges(feature_by_action)
    return unless load_edit("aemethod_edit__#{params[:id]}", "replace_cell__explorer")

    get_method_form_vars
Severity: Minor
Found in app/controllers/miq_ae_class_controller.rb - About 1 day 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 fields_get_form_vars has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

  def fields_get_form_vars
    @ae_class = MiqAeClass.find_by(:id => @edit[:ae_class_id])
    @in_a_form = true
    @in_a_form_fields = true
    if params[:item].blank? && !%w[accept save].include?(params[:button]) && params["action"] != "field_delete"
Severity: Minor
Found in app/controllers/miq_ae_class_controller.rb - About 1 day 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_view has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

  def get_view(db, options = {}, fetch_data = false)
    if !fetch_data && @report_data_additional_options.nil?
      process_show_list_options(options, db)
    end
    if @in_a_form && @edit.present?
Severity: Minor
Found in app/controllers/application_controller.rb - About 1 day 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 button has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

  def button
    @edit = session[:edit] # Restore @edit for adv search box
    params[:display] = @display if %w[all_vms vms hosts resource_pools].include?(@display) # Were we displaying sub-items

    if params[:pressed].starts_with?("vm_", # Handle buttons from sub-items screen
Severity: Minor
Found in app/controllers/ems_cluster_controller.rb - About 1 day 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

File schedules.rb has 694 lines of code (exceeds 400 allowed). Consider refactoring.
Open

module OpsController::Settings::Schedules
  extend ActiveSupport::Concern

  # Show the main Schedules list view
  def schedules_list
Severity: Major
Found in app/controllers/ops_controller/settings/schedules.rb - About 1 day to fix

File diagnostics.rb has 689 lines of code (exceeds 400 allowed). Consider refactoring.
Open

module OpsController::Diagnostics
  extend ActiveSupport::Concern

  def diagnostics_tree_select
    assert_privileges("ops_diagnostics")
Severity: Major
Found in app/controllers/ops_controller/diagnostics.rb - About 1 day to fix

File filter.rb has 675 lines of code (exceeds 400 allowed). Consider refactoring.
Open

module ApplicationController::Filter
  extend ActiveSupport::Concern
  include ::MiqExpression::SubstMixin
  include ApplicationController::ExpressionHtml
  included do
Severity: Major
Found in app/controllers/application_controller/filter.rb - About 1 day to fix

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

  def replace_right_cell(options = {})
    @explorer = true
    action = options[:action]
    replace_trees = options[:replace_trees] || []
    get_node_info unless @in_a_form
Severity: Major
Found in app/controllers/report_controller.rb - About 1 day to fix
Severity
Category
Status
Source
Language