Showing 58 of 185 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);
- Read upRead up
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: {
Class Proxmox
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Proxmox < ComputeResource
include ProxmoxVmHelper
include ProxmoxConnection
include ProxmoxVmNew
include ProxmoxVmCommands
Function NetworkInterface
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
const NetworkInterface = ({
id,
networks,
bridges,
data,
- Read upRead up
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')
- Read upRead up
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
- Read upRead up
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';
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
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: {
File ProxmoxVmType.js
has 251 lines of code (exceeds 250 allowed). Consider refactoring. Open
import React, { useState, useEffect } from 'react';
import {
PageSection,
Divider,
Tabs,
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';
Function ProxmoxVmType
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
const ProxmoxVmType = ({
vmAttrs,
nodes,
images,
pools,
- Read upRead up
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']
- Read upRead up
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';
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 }
- Read upRead up
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]`,
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)
- Read upRead up
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') {
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) {
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?
- Read upRead up
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"