ManageIQ/manageiq-ui-classic

View on GitHub

Showing 18,390 of 18,390 total issues

Method alert_field_changed has 120 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def alert_field_changed
    return unless load_edit("miq_alert_edit__#{params[:id]}")

    @alert = @edit[:alert_id] ? MiqAlert.find(@edit[:alert_id]) : MiqAlert.new

Severity: Major
Found in app/controllers/miq_alert_controller.rb - About 4 hrs to fix

Function GroupForm has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

const GroupForm = ({
  recId, availableFields, fields, url, appliesToClass, appliesToId, isGenericObject,
}) => {
  const [{
    isLoading, initialValues, buttonIcon, options,
Severity: Minor
Found in app/javascript/components/button-group/index.jsx - About 4 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_set_show_vars has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

  def prov_set_show_vars
    @showtype = "main"
    @options = @miq_request.get_options # Get the provision options from the request record
    @options[:org_controller] = "vm"
    if @options[:schedule_time]
Severity: Minor
Found in app/controllers/application_controller/miq_request_methods.rb - About 4 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 set_dates has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    def set_dates(start_date, end_date, allow_interval_override)
      tz = time_profile_tz || self.tz # Use time profile tz or chosen tz, if no profile tz
      self.sdate = start_date.in_time_zone(tz)
      self.edate = end_date.in_time_zone(tz)
      self.sdate_daily = sdate.hour.zero? ? sdate : sdate + 1.day
Severity: Minor
Found in app/controllers/application_controller/performance/options.rb - About 4 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_node_info has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

  def get_node_info(treenodeid, refresh = nil)
    treenodeid = valid_active_node(treenodeid)
    get_nodetype_and_record(treenodeid)
    @right_cell_text = if @record.kind_of?(MiqEnterprise)
                         _('Enterprise')
Severity: Minor
Found in app/controllers/utilization_controller.rb - About 4 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 log_depot_edit has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

  def log_depot_edit
    assert_privileges("#{@sb[:selected_typ] == "miq_server" ? "" : "zone_"}log_depot_edit")
    @record = @sb[:selected_typ].classify.constantize.find(@sb[:selected_server_id])
    # @schedule = nil # setting to nil, since we are using same view for both db_back and log_depot edit
    case params[:button]
Severity: Minor
Found in app/controllers/ops_controller/diagnostics.rb - About 4 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

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

                  <a href={data.notification.href}>
                    { data.notification.iconImage && <img src={data.notification.iconImage} alt="" className="card-pf-icon-image" /> }
                    { data.notification.iconClass && <span className={data.notification.iconClass} /> }
                    { data.notification.count && (
                      <span>
Severity: Major
Found in app/javascript/components/pf_aggregate_status_card.jsx and 1 other location - About 4 hrs to fix
app/javascript/components/pf_aggregate_status_card.jsx on lines 105..114

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

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

    } else if (confirm(__('An updated subscription must point to the same database with which it was originally created. Failure to do so will result in undefined behavior. Do you want to continue?'))) {
      $scope.pglogicalReplicationModel.s_index       = idx;
      $scope.pglogicalReplicationModel.updateEnabled = true;
      $scope.pglogicalReplicationModel.dbname        = subscription.dbname;
      $scope.pglogicalReplicationModel.host          = subscription.host;
app/javascript/oldjs/controllers/ops/pglogical_replication_form_controller.js on lines 113..129

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

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

    if (subscription.newRecord === true) {
      $scope.pglogicalReplicationModel.s_index       = idx;
      $scope.pglogicalReplicationModel.updateEnabled = true;
      $scope.pglogicalReplicationModel.dbname        = subscription.dbname;
      $scope.pglogicalReplicationModel.host          = subscription.host;
app/javascript/oldjs/controllers/ops/pglogical_replication_form_controller.js on lines 121..129

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

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

                  <span>
                    { data.notification.iconImage && <img src={data.notification.iconImage} alt="" className="card-pf-icon-image" /> }
                    { data.notification.iconClass && <span className={data.notification.iconClass} /> }
                    { data.notification.count && (
                      <span>
Severity: Major
Found in app/javascript/components/pf_aggregate_status_card.jsx and 1 other location - About 4 hrs to fix
app/javascript/components/pf_aggregate_status_card.jsx on lines 93..102

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

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

Cyclomatic complexity for form_method_field_changed is too high. [37/11]
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

Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.

def each_child_node(*types)               # count begins: 1
  unless block_given?                     # unless: +1
    return to_enum(__method__, *types)

  children.each do |child|                # each{}: +1
    next unless child.is_a?(Node)         # unless: +1

    yield child if types.empty? ||        # if: +1, ||: +1
                   types.include?(child.type)
  end

  self
end                                       # total: 6

Cyclomatic complexity for build_selected_fields is too high. [37/11]
Open

  def build_selected_fields(rpt)
    fields = []
    headers = {}
    col_formats = {}
    pivot_cols = {}

Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.

def each_child_node(*types)               # count begins: 1
  unless block_given?                     # unless: +1
    return to_enum(__method__, *types)

  children.each do |child|                # each{}: +1
    next unless child.is_a?(Node)         # unless: +1

    yield child if types.empty? ||        # if: +1, ||: +1
                   types.include?(child.type)
  end

  self
end                                       # total: 6

Class GenericObjectDefinitionController has 36 methods (exceeds 20 allowed). Consider refactoring.
Open

class GenericObjectDefinitionController < ApplicationController
  before_action :check_privileges
  before_action :get_session_data

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

Class ExplorerPresenter has 36 methods (exceeds 20 allowed). Consider refactoring.
Open

class ExplorerPresenter
  include ApplicationHelper
  include JsHelper
  include ActionView::Helpers::JavaScriptHelper

Severity: Minor
Found in app/presenters/explorer_presenter.rb - About 4 hrs to fix

File ems_common.rb has 511 lines of code (exceeds 400 allowed). Consider refactoring.
Open

module Mixins
  module EmsCommon
    extend ActiveSupport::Concern

    # This is the list of extracted parts that can be used separately
Severity: Major
Found in app/controllers/mixins/ems_common.rb - About 4 hrs to fix

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

const getSortedHash = (inputHash) => {
  const sortedHash = Object.keys(inputHash)
    .map((key) => ({ k: key, v: inputHash[key] }))
    .sort((a, b) => a.v.localeCompare(b.v))
    .reduce((o, e) => {
app/javascript/components/ansible-playbook-edit-catalog-form/helper.js on lines 39..48

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

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

const getSortedHash = (inputHash) => {
  const sortedHash = Object.keys(inputHash)
    .map((key) => ({ k: key, v: inputHash[key] }))
    .sort((a, b) => a.v.localeCompare(b.v))
    .reduce((o, e) => {
app/javascript/components/terraform-template-catalog-form/helper.js on lines 39..48

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

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

Function processReplaceRightCell has 116 lines of code (exceeds 25 allowed). Consider refactoring.
Open

ManageIQ.explorer.processReplaceRightCell = function(data) {
  /* variables for the expression editor */
  if (_.isObject(data.expEditor)) {
    if (_.isObject(data.expEditor.first)) {
      if (!_.isUndefined(data.expEditor.first.type)) {
Severity: Major
Found in app/javascript/oldjs/miq_explorer.js - About 4 hrs to fix

Method center_toolbar_filename_classic has 116 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def center_toolbar_filename_classic
    # Original non vmx view code follows
    # toolbar buttons on sub-screens
    to_display = %w[availability_zones cloud_networks cloud_object_store_containers cloud_subnets configured_systems
                    cloud_tenants cloud_volumes cloud_volume_snapshots ems_clusters flavors floating_ips host_aggregates hosts host_initiators host_initiator_groups
Severity: Major
Found in app/helpers/application_helper/toolbar_chooser.rb - About 4 hrs to fix

Function hostData has 115 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const hostData = () => {
  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 4 hrs to fix
Severity
Category
Status
Source
Language