theforeman/foreman_fog_proxmox

View on GitHub

Showing 57 of 186 total issues

Function ProxmoxServerStorage has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

const ProxmoxServerStorage = ({ storage, storages, paramScope, nodeId }) => {
  const [hardDisks, setHardDisks] = useState([]);
  const [nextId, setNextId] = useState(0);
  const [cdRom, setCdRom] = useState(false);
  const [cdRomData, setCdRomData] = useState(null);
Severity: Minor
Found in webpack/components/ProxmoxServer/ProxmoxServerStorage.js - 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

Function addInterface has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    (event, initialData = null) => {
      if (event) event.preventDefault();
      const netId = getLowestAvailableId();
      const initData = initialData || {
        id: {
Severity: Major
Found in webpack/components/ProxmoxContainer/ProxmoxContainerNetwork.js - About 2 hrs to fix

    Class Proxmox has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Proxmox < ComputeResource
        include ProxmoxVmHelper
        include ProxmoxConnection
        include ProxmoxVmNew
        include ProxmoxVmCommands
    Severity: Minor
    Found in app/models/foreman_fog_proxmox/proxmox.rb - About 2 hrs to fix

      Function NetworkInterface has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      const NetworkInterface = ({
        id,
        networks,
        bridges,
        data,
      Severity: Minor
      Found in webpack/components/ProxmoxContainer/components/NetworkInterface.js - 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 update_volume has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def update_volume(vm, disk, volume_attributes)
            id = disk.id
            if volume_type?(volume_attributes, 'cdrom')
              update_cdrom(vm, disk, volume_attributes)
            elsif volume_type?(volume_attributes, 'hard_disk')
      Severity: Minor
      Found in app/models/foreman_fog_proxmox/proxmox_volumes.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 setVmDetails has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

            def setVmDetails
              attrs = compute_resource.provided_attributes
              result = true
              attrs.each do |foreman_attr, fog_attr|
                if foreman_attr == :mac
      Severity: Minor
      Found in app/models/concerns/orchestration/proxmox/compute.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

      File ProxmoxServerStorage.js has 256 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import React, { useState, useEffect, useCallback } from 'react';
      import PropTypes from 'prop-types';
      import { Title, PageSection, Button } from '@patternfly/react-core';
      import { TimesIcon } from '@patternfly/react-icons';
      import { sprintf, translate as __ } from 'foremanReact/common/I18n';
      Severity: Minor
      Found in webpack/components/ProxmoxServer/ProxmoxServerStorage.js - About 2 hrs to fix

        File proxmox_vm.js has 254 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        // Copyright 2018 Tristan Robert
        
        // This file is part of ForemanFogProxmox.
        
        // ForemanFogProxmox is free software: you can redistribute it and/or modify
        Severity: Minor
        Found in app/assets/javascripts/foreman_fog_proxmox/proxmox_vm.js - About 2 hrs to fix

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

              (event, initialData = null) => {
                if (event) event.preventDefault();
                const netId = getLowestAvailableId();
                const initData = initialData || {
                  id: {
          Severity: Major
          Found in webpack/components/ProxmoxServer/ProxmoxServerNetwork.js - About 2 hrs to fix

            Function addHardDisk has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                (event, initialData = null, isPreExisting = false) => {
                  if (event) event.preventDefault();
                  let deviceInfo = null;
                  if (!isPreExisting) {
                    const selectedController = initialData?.controller?.value || 'virtio';
            Severity: Minor
            Found in webpack/components/ProxmoxServer/ProxmoxServerStorage.js - About 1 hr to fix

              Function ProxmoxVmType has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

              const ProxmoxVmType = ({
                vmAttrs,
                nodes,
                images,
                pools,
              Severity: Minor
              Found in webpack/components/ProxmoxVmType.js - About 1 hr 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 parse_server_cloudinit has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                def parse_server_cloudinit(args)
                  cloudinit_h = {}
                  cloudinit = args['cloudinit']
                  unless ['none'].include? cloudinit
                    volid = args['volid']
              Severity: Minor
              Found in app/helpers/proxmox_vm_cloudinit_helper.rb - About 1 hr 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 handleChange has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                const handleChange = e => {
                  const { name, type, checked, value: targetValue } = e.target;
                  let value;
                  if (type === 'checkbox') {
                    value = checked ? '1' : '0';
              Severity: Minor
              Found in webpack/components/ProxmoxContainer/components/NetworkInterface.js - About 1 hr to fix

                Method object_to_attributes_hash has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                  def object_to_attributes_hash(vms, from_profile, start_checked)
                    param_scope = from_profile ? "compute_attribute[vm_attrs]" : "host[compute_attributes]"
                    vm_h = ActiveSupport::HashWithIndifferentAccess.new
                    keys = [:vmid, :node_id, :type, :pool]
                    main = vms.attributes.select { |key, _value| keys.include? key }
                Severity: Minor
                Found in app/helpers/proxmox_vm_attrs_helper.rb - About 1 hr 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 addMountPoint has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    (event, initialData = null) => {
                      if (event) event.preventDefault();
                      const initMP = initialData || {
                        id: {
                          name: `${paramScope}[volumes_attributes][${nextId}][id]`,
                Severity: Minor
                Found in webpack/components/ProxmoxContainer/ProxmoxContainerStorage.js - About 1 hr to fix

                  Method create_vm has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def create_vm(args = {})
                        type = args[:type]
                        node = client.nodes.get(args[:node_id])
                        vmid = args[:vmid] = assign_vmid(args[:vmid].to_i, node)
                        raise ::Foreman::Exception, format(N_('invalid vmid=%<vmid>s'), vmid: vmid) unless node.servers.id_valid?(vmid)
                  Severity: Minor
                  Found in app/models/foreman_fog_proxmox/proxmox_vm_commands.rb - About 1 hr 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 handleChange has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    const handleChange = e => {
                      const { name, value } = e.target;
                      const updatedKey = Object.keys(hdd).find(key => hdd[key].name === name);
                  
                      if (updatedKey === 'controller') {
                  Severity: Minor
                  Found in webpack/components/ProxmoxServer/components/HardDisk.js - About 1 hr to fix

                    Function updateOptions has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function updateOptions(options_path, start_options_id, end_options_id, start_second_options_id, end_second_options_id, option_id, node_id, second_id) {
                      
                      var select_ids = selectIds(start_options_id, end_options_id);
                      var select_second_ids;
                      if ( start_second_options_id != undefined && end_second_options_id != undefined) {
                    Severity: Minor
                    Found in app/assets/javascripts/foreman_fog_proxmox/proxmox_vm.js - About 1 hr to fix

                      Method host_interfaces_attrs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def host_interfaces_attrs(host)
                            host.interfaces.select(&:physical?).each.with_index.reduce({}) do |hash, (nic, index)|
                              set_nic_identifier(nic, index)
                              set_container_interface_name(host, nic, index) if container?(host)
                              ForemanFogProxmox::HashCollection.remove_empty_values(nic.compute_attributes)
                      Severity: Minor
                      Found in app/models/foreman_fog_proxmox/proxmox_interfaces.rb - About 1 hr 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 parse_hard_disk_volume has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def parse_hard_disk_volume(args)
                          logger.debug(format(_('parse_hard_disk_volume(): args=%<args>s'), args: args))
                          disk = {}
                          disk[:id] = args['id'] if args.key?('id')
                          disk[:volid] = args['volid'] if args.key?('volid') && !args['volid'].empty?
                      Severity: Minor
                      Found in app/helpers/proxmox_vm_volumes_helper.rb - About 1 hr 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