ManageIQ/manageiq-ui-classic

View on GitHub

Showing 18,390 of 18,390 total issues

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

export const alertReferencedData = {
  title: _('Referenced by Actions'),
  mode: 'miq_alert_referenced',
  message: _('This Alert is not referenced by any Actions.'),
  items: [
Severity: Major
Found in app/javascript/spec/miq-alert/miq-alert.data.js and 2 other locations - About 5 hrs to fix
app/javascript/spec/miq-condition/miq-condition.data.js on lines 31..58
app/javascript/spec/miq-alert/miq-alert.data.js on lines 92..119

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

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 conditionPoliciesData = {
  title: _('Assigned to Policies'),
  mode: 'miq_condition_policies',
  message: _('This Condition is not assigned to any Policies.'),
  items: [
Severity: Major
Found in app/javascript/spec/miq-condition/miq-condition.data.js and 2 other locations - About 5 hrs to fix
app/javascript/spec/miq-alert/miq-alert.data.js on lines 92..119
app/javascript/spec/miq-alert/miq-alert.data.js on lines 121..148

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

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 createSchema has 141 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const createSchema = (credentials, credentialReferences, payloadCredentials, workflowAuthentications, setState) => {
  // Saves a new credential mapping to 'credentials'
  const mapCredentials = () => setState((state) => {
    if (state.workflowCredentials && state.credentialField) {
      return ({

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

const createSchema = (credentials, credentialReferences, payloadCredentials, workflowAuthentications, setState) => {
  // Saves a new credential mapping to 'credentials'
  const mapCredentials = () => setState((state) => {
    if (state.workflowCredentials && state.credentialField) {
      return ({

File widgets.rb has 551 lines of code (exceeds 400 allowed). Consider refactoring.
Open

module ReportController::Widgets
  extend ActiveSupport::Concern

  RIGHT_CELL_TEXTS = {
    "r"  => [N_('Report Widgets'),   N_('Report Widget "%{name}"')],
Severity: Major
Found in app/controllers/report_controller/widgets.rb - About 5 hrs to fix

Function provisionTabSchema has 140 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const provisionTabSchema = (
  repositories,
  setData,
  provisionRepositoryId,
  currentRegion,

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

  const areaOptions = {
    grid: {
      x: {
        enabled: false,
      },
app/javascript/components/provider-dashboard-charts/provider-dashboard-utilization-chart/utilizationDonutChart.js on lines 37..75

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

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

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

  const areaOptions = {
    grid: {
      x: {
        enabled: false,
      },
app/javascript/components/provider-dashboard-charts/provider-dashboard-utilization-chart/utilizationMemoryDonutChart.js on lines 37..75

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

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 update_from_params has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    def update_from_params(params)
      self.typ         = params[:perf_typ]          if params[:perf_typ]
      self.days        = params[:perf_days]         if params[:perf_days]
      self.rt_minutes  = params[:perf_minutes].to_i if params[:perf_minutes]
      self.hourly_date = params[:miq_date_1]        if params[:miq_date_1] && typ == 'Hourly'
Severity: Minor
Found in app/controllers/application_controller/performance/options.rb - About 5 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 rbac_field_changed has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

  def rbac_field_changed(rec_type)
    id = params[:id].split('__').first || 'new' # Get the record id
    id = id unless %w[new seq].include?(id)
    return unless load_edit("rbac_#{rec_type}_edit__#{id}", "replace_cell__explorer")

Severity: Minor
Found in app/controllers/ops_controller/ops_rbac.rb - About 5 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 gfv_key_style has a Cognitive Complexity of 37 (exceeds 5 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: Minor
Found in app/controllers/report_controller/reports/editor.rb - About 5 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

  const onSubmit = ({ edit: _edit, ...values }) => {
    if (values.ems_id !== '-1') {
      miqSparkleOn();

      const request = recordId ? API.patch(`/api/storage_services/${recordId}`, values) : API.post('/api/storage_services', values);
Severity: Major
Found in app/javascript/components/storage-service-form/index.jsx and 1 other location - About 5 hrs to fix
app/javascript/components/cloud-volume-form/index.jsx on lines 45..60

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

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 onSubmit = ({ edit: _edit, ...values }) => {
    if (values.ems_id !== '-1') {
      miqSparkleOn();

      const request = recordId ? API.patch(`/api/cloud_volumes/${recordId}`, values) : API.post('/api/cloud_volumes', values);
Severity: Major
Found in app/javascript/components/cloud-volume-form/index.jsx and 1 other location - About 5 hrs to fix
app/javascript/components/storage-service-form/index.jsx on lines 53..69

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

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 createSchema has 138 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const createSchema = (fields, edit, ems, loadSchema, emptySchema) => {
  const idx = fields.findIndex((field) => field.name === 'volume_type');
  const supports = edit ? 'supports_cloud_volume' : 'supports_cloud_volume_create';
  let providerCapabilities;

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

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 schedule_get_form_vars is too high. [44/11]
Open

  def schedule_get_form_vars
    @schedule = @edit[:sched_id] ? MiqSchedule.find(@edit[:sched_id]) : MiqSchedule.new(:userid => session[:userid])
    copy_params_if_present(@edit[:new], params, %i[name description])
    @edit[:new][:enabled] = (params[:enabled] == "1") if params[:enabled]
    @edit[:new][:filter] = params[:filter_typ] if params[:filter_typ]

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 MiqRequestController has 41 methods (exceeds 20 allowed). Consider refactoring.
Open

class MiqRequestController < ApplicationController
  include Mixins::GenericSessionMixin
  include Mixins::BreadcrumbsMixin

  before_action :check_privileges, :except => :post_install_callback
Severity: Minor
Found in app/controllers/miq_request_controller.rb - About 5 hrs to fix

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

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

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

    submitParams: {
      disks: { add: [], resize: [], delete: [] },
      diskIds: {
        add: [], resize: [], delete: [], backup: [],
      },
Severity: Major
Found in app/javascript/components/reconfigure-vm-form/index.jsx and 1 other location - About 5 hrs to fix
app/javascript/components/reconfigure-vm-form/index.jsx on lines 99..108

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

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

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

        submitParams: {
          disks: { add: [], resize: [], delete: [] },
          diskIds: {
            add: [], resize: [], delete: [], backup: [],
          },
Severity: Major
Found in app/javascript/components/reconfigure-vm-form/index.jsx and 1 other location - About 5 hrs to fix
app/javascript/components/reconfigure-vm-form/index.jsx on lines 44..53

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

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