ManageIQ/manageiq-ui-classic

View on GitHub

Showing 18,390 of 18,390 total issues

Method menu_folders has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def menu_folders(view)
    view.compact.map do |row|
      row_id = nil

      if @edit[:user_typ]
Severity: Minor
Found in app/controllers/report_controller/menus.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 x_get_tree_server_roles has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def x_get_tree_server_roles
    ServerRole.all.sort_by(&:description).each_with_object([]) do |r, objects|
      next if @root.kind_of?(MiqRegion) && !r.regional_role? # Only regional roles under Region
      next unless (@root.kind_of?(Zone) && r.miq_servers.any? { |s| s.my_zone == @root.name }) ||
                  (@root.kind_of?(MiqRegion) && !r.miq_servers.empty?) # Skip if no assigned servers in this zone
Severity: Minor
Found in app/presenters/tree_builder_servers_by_role.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 formOptions has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  var formOptions = function(vm) {
    miqService.sparkleOn();
    if (vm[vm.model].catalog_id !== undefined) {
      allApiPromises.push(API.get('/api/service_catalogs/?expand=resources&attributes=id,name' + sortOptions)
        .then(function(data) {
Severity: Major
Found in app/javascript/oldjs/controllers/playbook-reusable-code-mixin.js - About 2 hrs to fix

Function add_flash has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

window.add_flash = function(msg, level, options) {
  level = level || 'success';
  options = options || {};
  var cls = { alert: '', icon: '' };

Severity: Major
Found in app/javascript/oldjs/miq_flash.js - About 2 hrs to fix

Function deleteNetwork has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const deleteNetwork = (row, data, setData, roles) => {
  let dataTableData = data.dataTable.networkAdapters || [];
  let submitNetworks = data.submitParams.networks.add || [];
  let addNetworkIds = data.submitParams.networkIds.add || [];
  const deleteNetworksData = data.submitParams.networks.delete || [];
Severity: Major
Found in app/javascript/components/reconfigure-vm-form/helpers/network.js - About 2 hrs to fix

Method dialog_form_button_pressed has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def dialog_form_button_pressed
    case params[:button]
    when "cancel"
      return unless load_edit("dialog_edit__#{params[:id]}", "replace_cell__explorer")

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

Method x_button has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def x_button
    model, action = pressed2model_action(params[:pressed])
    allowed_models = %w[common image instance vm miq_template provider automation storage infra_networking]
    raise ActionController::RoutingError, 'Invalid button action' unless
      allowed_models.include?(model)
Severity: Major
Found in app/controllers/application_controller/explorer.rb - About 2 hrs to fix

Method exp_commit_find has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def exp_commit_find(exp)
    if @edit[@expkey][:exp_field].nil?
      add_flash(_("A find field must be chosen to commit this expression element"), :error)
    elsif %w[checkall checkany].include?(@edit[@expkey][:exp_check]) &&
          @edit[@expkey][:exp_cfield].nil?
Severity: Major
Found in app/controllers/application_controller/filter.rb - About 2 hrs to fix

Method buttons_get_node_info has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def buttons_get_node_info(node)
    nodetype = node.split("_")
    # initializing variables to hold data for selected node
    @custom_button = nil
    @sb[:button_groups] = nil
Severity: Major
Found in app/controllers/application_controller/buttons.rb - About 2 hrs to fix

Method cu_build_edit_screen has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def cu_build_edit_screen
    @edit = {}
    @edit[:new] = {}
    @edit[:current] = {}
    @edit[:key] = "cu_edit__collection"
Severity: Major
Found in app/controllers/ops_controller/settings/cap_and_u.rb - About 2 hrs to fix

Method action_field_changed has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def action_field_changed
    return unless load_edit("miq_action_edit__#{params[:id]}")

    @action = @edit[:action_id] ? MiqAction.find(@edit[:action_id]) : MiqAction.new

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

Method provision_dialogs_update_create has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def provision_dialogs_update_create
    case params[:button]
    when "add", "save"
      dialog = params[:id].blank? ? MiqDialog.new : MiqDialog.find(params[:id]) # Get new or existing record
      if params[:name].blank?
Severity: Major
Found in app/controllers/miq_ae_customization_controller/old_dialogs.rb - About 2 hrs to fix

Method set_form_vars has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def set_form_vars
    @edit[:new][:name] = @record.name
    @edit[:new][:description] = @record.description
    @edit[:new][:long_description] = @record.long_description
    @edit[:new][:provision_cost] = @record.provision_cost
Severity: Major
Found in app/controllers/catalog_controller.rb - About 2 hrs to fix

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

export const actionTypeData3 = {
  title: _('Alerts to Evaluate'),
  mode: 'miq_action_info',
  message: _('No Alerts have been selected.'),
  items: [
Severity: Major
Found in app/javascript/spec/miq-action/miq-action.data.js and 2 other locations - About 2 hrs to fix
app/javascript/spec/miq-alert-set/miq-alert-set.data.js on lines 38..51
app/javascript/spec/miq-event-definition/miq-event-definition.data.js on lines 10..23

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 76.

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 3 locations. Consider refactoring.
Open

  it('should create an action to delete set tag', () => {
    const tag = { tagCategory: 'cat', tagValue: 'val' };
    const expectedAction = {
      type: actionsConstants.DELETE_ASSIGNED_TAG,
      tag,
Severity: Major
Found in app/javascript/tagging/tests/actions.test.js and 2 other locations - About 2 hrs to fix
app/javascript/tagging/tests/actions.test.js on lines 14..21
app/javascript/tagging/tests/actions.test.js on lines 32..39

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 76.

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 3 locations. Consider refactoring.
Open

  it('should create an action to add set tag', () => {
    const tag = { tagCategory: 'cat', tagValue: 'val' };
    const expectedAction = {
      type: actionsConstants.CHANGE_ASSIGNED_TAGS,
      tag,
Severity: Major
Found in app/javascript/tagging/tests/actions.test.js and 2 other locations - About 2 hrs to fix
app/javascript/tagging/tests/actions.test.js on lines 14..21
app/javascript/tagging/tests/actions.test.js on lines 23..30

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 76.

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 3 locations. Consider refactoring.
Open

export const alertSetAlerts = {
  title: __('Alerts'),
  mode: 'miq_alert_set',
  message: __('This Action is not assigned to any Policies.'),
  items: [
Severity: Major
Found in app/javascript/spec/miq-alert-set/miq-alert-set.data.js and 2 other locations - About 2 hrs to fix
app/javascript/spec/miq-action/miq-action.data.js on lines 36..49
app/javascript/spec/miq-event-definition/miq-event-definition.data.js on lines 10..23

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 76.

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 3 locations. Consider refactoring.
Open

  it('should create an action to toggle tag value change', () => {
    const tag = { tagCategory: 'cat', tagValue: 'val' };
    const expectedAction = {
      type: actionsConstants.TOGGLE_TAG_VALUE_CHANGE,
      tag,
Severity: Major
Found in app/javascript/tagging/tests/actions.test.js and 2 other locations - About 2 hrs to fix
app/javascript/tagging/tests/actions.test.js on lines 23..30
app/javascript/tagging/tests/actions.test.js on lines 32..39

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 76.

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 3 locations. Consider refactoring.
Open

export const eventDefinitionPolicyData = {
  title: _('Assigned to Policies'),
  mode: 'miq_event_definition_policy',
  message: _('This Event is not assigned to any Policies.'),
  items: [
app/javascript/spec/miq-action/miq-action.data.js on lines 36..49
app/javascript/spec/miq-alert-set/miq-alert-set.data.js on lines 38..51

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 76.

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

          <div className="col-xs-12 col-sm-12 col-md-12 col-lg-6 example-trend-container">
            {processData.memory.dataAvailable
              ? (
                <UtilizationMemoryDonutChart
                  data={data.metricsData}
app/javascript/components/provider-dashboard-charts/provider-dashboard-utilization-chart/index.js on lines 58..68

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 76.

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

Severity
Category
Status
Source
Language