ManageIQ/manageiq-ui-classic

View on GitHub

Showing 8,732 of 8,732 total issues

File routes.rb has 3097 lines of code (exceeds 400 allowed). Consider refactoring.
Open

Rails.application.routes.draw do
  # rubocop:disable Layout/HashAlignment
  # rubocop:disable Layout/MultilineOperationIndentation
  # default routes for each controller
  default_routes = %w(
Severity: Major
Found in config/routes.rb - About 1 wk to fix

File miq_ae_class_controller.rb has 2542 lines of code (exceeds 400 allowed). Consider refactoring.
Open

require "rexml/document"
class MiqAeClassController < ApplicationController
  include MiqAeClassHelper
  include AutomateTreeHelper
  include Mixins::GenericSessionMixin
Severity: Major
Found in app/controllers/miq_ae_class_controller.rb - About 6 days to fix

Method update_from_expression_editor has a Cognitive Complexity of 271 (exceeds 5 allowed). Consider refactoring.
Open

    def update_from_expression_editor(params)
      if params[:chosen_typ] && params[:chosen_typ] != exp_typ
        change_exp_typ(params[:chosen_typ])
      else
        case exp_typ
Severity: Minor
Found in app/controllers/application_controller/filter/expression.rb - About 5 days 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 catalog_controller.rb has 2000 lines of code (exceeds 400 allowed). Consider refactoring.
Open

class CatalogController < ApplicationController
  include AutomateTreeHelper
  include ServiceDialogCreationMixin
  include Mixins::BreadcrumbsMixin

Severity: Major
Found in app/controllers/catalog_controller.rb - About 5 days to fix

File compare.rb has 1629 lines of code (exceeds 400 allowed). Consider refactoring.
Open

module ApplicationController::Compare
  extend ActiveSupport::Concern

  DRIFT_TIME_COLUMNS = %w[last_scan_on boot_time last_logon].freeze

Severity: Major
Found in app/controllers/application_controller/compare.rb - About 3 days to fix

File application_controller.rb has 1536 lines of code (exceeds 400 allowed). Consider refactoring.
Open

require 'open-uri'

# Need to make sure models are autoloaded
MiqCompare
MiqFilter
Severity: Major
Found in app/controllers/application_controller.rb - About 3 days to fix

File editor.rb has 1486 lines of code (exceeds 400 allowed). Consider refactoring.
Open

module ReportController::Reports::Editor
  extend ActiveSupport::Concern

  included do
    helper_method :cashed_reporting_available_fields, :cashed_reporting_available_fields
Severity: Major
Found in app/controllers/report_controller/reports/editor.rb - About 3 days to fix

Class MiqAeClassController has 162 methods (exceeds 20 allowed). Consider refactoring.
Open

class MiqAeClassController < ApplicationController
  include MiqAeClassHelper
  include AutomateTreeHelper
  include Mixins::GenericSessionMixin
  include Mixins::BreadcrumbsMixin
Severity: Major
Found in app/controllers/miq_ae_class_controller.rb - About 3 days to fix

Method settings_get_form_vars has a Cognitive Complexity of 156 (exceeds 5 allowed). Consider refactoring.
Open

Severity: Minor
Found in app/controllers/ops_controller/settings/common.rb - About 3 days 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 replace_right_cell has a Cognitive Complexity of 148 (exceeds 5 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: Minor
Found in app/controllers/report_controller.rb - About 3 days 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 ap_edit has a Cognitive Complexity of 141 (exceeds 5 allowed). Consider refactoring.
Open

  def ap_edit
    assert_privileges("ap_edit")
    if params["accept"]
      ap_accept_line_changes
    else
Severity: Minor
Found in app/controllers/ops_controller/settings/analysis_profiles.rb - About 2 days 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

export const getMemoryChart = (isLoading, dashboardData) => {
  if (isLoading !== true) {
    if (dashboardData.data.project_utilization.dataAvailable) {
      const chartData = [];
      let count = 0;
Severity: Major
Found in app/javascript/components/container-projects/helper.jsx and 1 other location - About 2 days to fix
app/javascript/components/container-projects/helper.jsx on lines 102..179

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

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

export const getCPUChart = (isLoading, dashboardData) => {
  if (isLoading !== true) {
    if (dashboardData.data.project_utilization.dataAvailable) {
      const chartData = [];
      let count = 0;
Severity: Major
Found in app/javascript/components/container-projects/helper.jsx and 1 other location - About 2 days to fix
app/javascript/components/container-projects/helper.jsx on lines 181..258

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

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

File miq_application.js has 1207 lines of code (exceeds 400 allowed). Consider refactoring.
Open

/* global add_flash getChartColumnDataValues getChartFormatedValue miqBrowserDetect miqExpressionPrefill miqFlashLater miqFlashSaved miqGridCheckAll miqGridGetCheckedRows miqMenu miqTreeObject miqValueStylePrefill recalculateChartYAxisLabels */

// MIQ specific JS functions

// Things to be done on page loads
Severity: Major
Found in app/javascript/oldjs/miq_application.js - About 2 days to fix

Method st_get_form_vars has a Cognitive Complexity of 131 (exceeds 5 allowed). Consider refactoring.
Open

  def st_get_form_vars
    get_form_vars
    if params[:resource_id]
      # adding new service resource, so need to lookup actual vm or service template record and set defaults
      sr = ServiceTemplate.find(params[:resource_id])
Severity: Minor
Found in app/controllers/catalog_controller.rb - About 2 days 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 performance.rb has 1202 lines of code (exceeds 400 allowed). Consider refactoring.
Open

module ApplicationController::Performance
  extend ActiveSupport::Concern

  CHARTS_REPORTS_FOLDER = Rails.root.join("product", "charts", "miq_reports")
  CHARTS_LAYOUTS_FOLDER = Rails.root.join("product", "charts", "layouts")
Severity: Major
Found in app/controllers/application_controller/performance.rb - About 2 days to fix

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

function createSchema(recordId, promise, inheritTags, evaluateAlert, tags, ansibleInventory, snapshotAge, parentType, inventoryType) {
  const subForm = [
    {
      component: componentTypes.SUB_FORM,
      id: 'subform-1',
Severity: Major
Found in app/javascript/components/action-form/action-form.schema.js - About 2 days to fix

File vm_common.rb has 1171 lines of code (exceeds 400 allowed). Consider refactoring.
Open

module VmCommon
  extend ActiveSupport::Concern
  include ActionView::Helpers::JavaScriptHelper
  include ChargebackPreview
  include ProvisionCustomizeHelper
Severity: Major
Found in app/controllers/vm_common.rb - About 2 days to fix

File ops_rbac.rb has 1170 lines of code (exceeds 400 allowed). Consider refactoring.
Open

module OpsController::OpsRbac
  extend ActiveSupport::Concern

  TAG_DB_TO_NAME = {
    'MiqGroup' => 'group',
Severity: Major
Found in app/controllers/ops_controller/ops_rbac.rb - About 2 days to fix

Method menu_field_changed has a Cognitive Complexity of 123 (exceeds 5 allowed). Consider refactoring.
Open

  def menu_field_changed
    assert_privileges("miq_report_menu_editor")

    return unless load_edit("menu_edit__#{session[:role_choice] ? session[:role_choice] : "new"}", "replace_cell__explorer")
    menu_get_form_vars
Severity: Minor
Found in app/controllers/report_controller/menus.rb - About 2 days 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

Severity
Category
Status
Source
Language