ManageIQ/manageiq-ui-classic

View on GitHub

Showing 18,390 of 18,390 total issues

Method db_get_node_info has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def db_get_node_info
    model, rec_id, _ = TreeBuilder.extract_node_model_and_id(x_node)
    @sb[:nodes] = x_node.split('-')
    if @sb[:nodes].length == 1
      @default_ws = MiqWidgetSet.where_unique_on("default").where(:read_only => true).first
Severity: Minor
Found in app/controllers/report_controller/dashboards.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 status has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def status
    routes_count = if @ems.present?
                     @ems.respond_to?(:container_routes) ? @ems.container_routes.count : 0 # ems might not have routes
                   else
                     ContainerRoute.count
Severity: Minor
Found in app/services/container_dashboard_service.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 ToolbarList has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const ToolbarList = (props) => {
  const count = useContext(CountContext);
  const { items, title, id } = props;
  // Set this true for overflowmenu keydown event
  const [overflowTab, setOverflowTab] = useState(false);
Severity: Major
Found in app/javascript/components/toolbar/ToolbarList.jsx - About 2 hrs to fix

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

  def replace_right_cell(options = {})
    @explorer = true
    replace_trees = options[:replace_trees]

    # FIXME: is the following line needed?
Severity: Major
Found in app/controllers/miq_ae_class_controller.rb - About 2 hrs to fix

Method build_reconfigure_hash has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def build_reconfigure_hash(reconfigure_ids)
          @req = nil
          @reconfig_values = {}
          if @request_id == 'new'
            @reconfig_values = get_reconfig_info(reconfigure_ids)
Severity: Major
Found in app/controllers/mixins/actions/vm_actions/reconfigure.rb - About 2 hrs to fix

Method st_edit has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def st_edit
    assert_privileges(params[:id] ? 'catalogitem_edit' : 'catalogitem_new')

    # reset the active tree back to :sandt_tree, it was changed temporairly to display automate entry point tree in a popup div
    self.x_active_tree = 'sandt_tree'
Severity: Major
Found in app/controllers/catalog_controller.rb - About 2 hrs to fix

Method determine_api_endpoints has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def determine_api_endpoints(obj, display_options = {})
    base_name = obj.class.base_model.name
    case base_name
    when /EmsCluster/
      api_collection_name = "clusters"
Severity: Major
Found in app/services/dialog_local_service.rb - About 2 hrs to fix

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

  useEffect(() => {
    if (recordId) {
      miqSparkleOn();
      API.get(`/api/iso_images/${recordId}`).then((initialValues) => {
        setState({ initialValues, isLoading: false });
Severity: Major
Found in app/javascript/components/pxe-iso-image-form/index.jsx and 1 other location - About 2 hrs to fix
app/javascript/components/pxe-image-type-form/index.jsx on lines 12..20

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

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

  cpuUsageConfig: {
    chartId: 'cpuUsageChart',
    title: __('CPU'),
    units: __('Cores'),
    usageDataName: __('Used'),
app/javascript/components/provider-dashboard-charts/charts_config.js on lines 59..70

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

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

  memoryUsageConfig: {
    chartId: 'memUsageChart',
    title: __('Memory'),
    units: __('GB'),
    usageDataName: __('Used'),
app/javascript/components/provider-dashboard-charts/charts_config.js on lines 42..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 86.

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

  useEffect(() => {
    if (recordId) {
      miqSparkleOn();
      API.get(`/api/pxe_image_types/${recordId}`).then((initialValues) => {
        setState({ initialValues, isLoading: false });
Severity: Major
Found in app/javascript/components/pxe-image-type-form/index.jsx and 1 other location - About 2 hrs to fix
app/javascript/components/pxe-iso-image-form/index.jsx on lines 12..20

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

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

  $scope.$watch('vm._provisioning_repository', function(value) {
    if (value) {
      playbookReusableCodeMixin.repositoryChanged(vm, 'provisioning', value.id);
    } else {
      vm.aeMethodModel.provisioning_repository_id = '';
app/javascript/oldjs/controllers/catalog/catalog_item_form_controller.js on lines 333..340

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

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

  $scope.$watch('vm._provisioning_repository', function(value) {
    if (value) {
      playbookReusableCodeMixin.repositoryChanged(vm, 'provisioning', value.id);
    } else {
      vm.catalogItemModel.provisioning_repository_id = '';
app/javascript/angular/miq_ae_class/ae_method_form_controller.js on lines 199..206

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

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

export const setDiskFormSubmit = (data, setData, formData, roles, renderData) => {
  const dataTableData = data.dataTable.disks || [];
  if (data.form.action === 'add') {
    // code for add
    const id = `disk${dataTableData.length}`;
Severity: Major
Found in app/javascript/components/reconfigure-vm-form/helpers/disk.js - About 2 hrs to fix

Function CloudObjectStoreContainerForm has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const CloudObjectStoreContainerForm = () => {
  const [{
    initialValues, fields, isLoading,
  }, setState] = useState({});

Severity: Major
Found in app/javascript/components/cloud-object-store-container-form/index.jsx - About 2 hrs to fix

Method button has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

    if params[:pressed].starts_with?("vm_", # Handle buttons from sub-items screen
Severity: Major
Found in app/controllers/storage_controller.rb - About 2 hrs to fix

Method widget_get_form_vars has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def widget_get_form_vars
    @widget = @edit[:widget_id] ? MiqWidget.find(@edit[:widget_id]) : MiqWidget.new

    copy_params_if_set(@edit[:new], params, %i[title description])
    @edit[:new][:filter]  = params[:filter_typ]       if params[:filter_typ]
Severity: Major
Found in app/controllers/report_controller/widgets.rb - About 2 hrs to fix

Class SecurityGroupController has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

class SecurityGroupController < ApplicationController
  before_action :check_privileges
  before_action :get_session_data
  after_action :cleanup_action
  after_action :set_session_data
Severity: Minor
Found in app/controllers/security_group_controller.rb - About 2 hrs to fix

Class ContainerDashboardService has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

class ContainerDashboardService < DashboardService
  include ContainerServiceMixin
  include Mixins::CheckedIdMixin
  include TextualMixins::TextualRefreshStatus

Severity: Minor
Found in app/services/container_dashboard_service.rb - About 2 hrs to fix

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

  useEffect(() => {
    const url = `/${dashboard}/ems_utilization_data/${providerId}`;
    http.get(url)
      .then((response) => {
        setCardData({
app/javascript/components/provider-dashboard-charts/events-bar-chart/index.js on lines 12..22
app/javascript/components/provider-dashboard-charts/heat-map-chart/index.js on lines 11..20
app/javascript/components/provider-dashboard-charts/servers-pie-chart/index.js on lines 14..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 85.

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