theforeman/foreman_fog_proxmox

View on GitHub

Showing 185 of 185 total issues

Method set_ip has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def set_ip(host, nic, nic_compute_attributes, v6 = false)
      ip = nic.send(ip_s(v6).to_sym)
      if container?(host)
        if dhcp?(nic_compute_attributes, v6)
          ip = 'dhcp'
Severity: Minor
Found in app/models/foreman_fog_proxmox/proxmox_interfaces.rb - About 35 mins 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 check_cidr has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def check_cidr(nic_compute_attributes, v6, ip)
      valid = Fog::Proxmox::IpHelper.send(cidr_prefix_method(v6), cidr_prefix(nic_compute_attributes, v6))
      ipv = "IPv#{v6 ? '6' : '4'}"
      max = v6 ? 128 : 32
      checked = valid || ForemanFogProxmox::Value.empty?(ip)
Severity: Minor
Found in app/models/foreman_fog_proxmox/proxmox_interfaces.rb - About 35 mins 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 HardDisk has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const HardDisk = ({
  id,
  data,
  storages,
  disks,
Severity: Minor
Found in webpack/components/ProxmoxServer/components/HardDisk.js - About 35 mins 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

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

NetworkInterface.defaultProps = {
  networks: [],
  bridges: [],
  data: {},
  updateNetworkData: Function.prototype,
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 142..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 45.

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

NetworkInterface.defaultProps = {
  networks: [],
  bridges: [],
  data: {},
  updateNetworkData: Function.prototype,
Severity: Minor
Found in webpack/components/ProxmoxServer/components/NetworkInterface.js and 1 other location - About 30 mins to fix
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 187..193

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

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

const ProxmoxContainerOptions = ({ options, storages, nodeId }) => {
  const [opts, setOpts] = useState(options);
  const storagesMap = createStoragesMap(storages, 'vztmpl', nodeId);
  const volumesMap = imagesByStorage(storages, nodeId, 'local', 'vztmpl');
  const handleChange = e => {
Severity: Minor
Found in webpack/components/ProxmoxContainer/ProxmoxContainerOptions.js - About 25 mins 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_typed_volume has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_typed_volume(args, type)
    logger.debug("parse_typed_volume(#{type}): args=#{args}")
    disk = parse_hard_disk_volume(args) if volume_type?(args,
      'hard_disk') || volume_type?(args, 'mp') || volume_type?(args, 'rootfs')
    disk = parse_server_cloudinit(args) if volume_type?(args, 'cloud_init')
Severity: Minor
Found in app/helpers/proxmox_vm_volumes_helper.rb - About 25 mins 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_cloudinit_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_cloudinit_config(args)
    filenames = ["meta-data"]
    config_data = ["instance-id: #{args[:name]}"]
    user_data = args.delete(:user_data)
    return args if user_data == ''
Severity: Minor
Found in app/helpers/proxmox_vm_cloudinit_helper.rb - About 25 mins 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 volumes_attrs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def volumes_attrs(param_scope, volumes)
    vol_attrs = []
    volumes.each_with_index do |vol, id|
      keys = []
      type = ""
Severity: Minor
Found in app/helpers/proxmox_vm_attrs_helper.rb - About 25 mins 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 find_vm_in_servers_by_vmid has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def find_vm_in_servers_by_vmid(servers, vmid)
      vm = servers.get(vmid) unless ForemanFogProxmox::Value.empty?(vmid)
      pool_owner(vm) if vm
      vm
    rescue Fog::Errors::NotFound
Severity: Minor
Found in app/models/foreman_fog_proxmox/proxmox_vm_queries.rb - About 25 mins 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 parsed_typed_volumes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def parsed_typed_volumes(args, type, parsed_vm)
    logger.debug("parsed_typed_volumes(#{type}): args=#{args}")
    volumes_attributes = args['volumes_attributes']
    unless ForemanFogProxmox::Value.empty?(args['config_attributes'])
      volumes_attributes ||= args['config_attributes']['volumes_attributes']
Severity: Minor
Found in app/helpers/proxmox_vm_volumes_helper.rb - About 25 mins 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 ProxmoxServerHardware has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const ProxmoxServerHardware = ({ hardware }) => {
  const [hw, setHw] = useState(hardware);
  const [isModalOpen, setIsModalOpen] = useState(false);

  const handleChange = e => {
Severity: Minor
Found in webpack/components/ProxmoxServer/ProxmoxServerHardware.js - About 25 mins 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 vm_compute_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def vm_compute_attributes(vm)
      vm_attrs = {}
      vm_attrs = vm_attrs.merge(vmid: vm.identity, node_id: vm.node_id, type: vm.type)
      if vm.respond_to?(:config)
        if vm.config.respond_to?(:disks)
Severity: Minor
Found in app/models/foreman_fog_proxmox/proxmox_compute_attributes.rb - About 25 mins 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 to_semver has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def self.to_semver(version)
      raise ArgumentError unless semver?(version)

      version_a = version.scan(SEMVER_REGEX)
      raise ArgumentError if version_a.empty?
Severity: Minor
Found in lib/foreman_fog_proxmox/semver.rb - About 25 mins 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 add_or_delete_typed_interface has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def add_or_delete_typed_interface(interface_attributes, interfaces_to_delete, interfaces_to_add, type)
    logger.debug("add_or_delete_typed_interface(#{type}): interface_attributes=#{interface_attributes}")
    ForemanFogProxmox::HashCollection.remove_empty_values(interface_attributes)
    if interface_attributes['compute_attributes']
      ForemanFogProxmox::HashCollection.remove_empty_values(interface_attributes['compute_attributes'])
Severity: Minor
Found in app/helpers/proxmox_vm_interfaces_helper.rb - About 25 mins 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 compute_dhcps has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def compute_dhcps(interface_attributes_h)
    interface_attributes_h[:dhcp] = (interface_attributes_h[:ip] == 'dhcp') ? '1' : '0'
    interface_attributes_h[:ip] = '' if interface_attributes_h[:dhcp] == '1'
    interface_attributes_h[:dhcp6] = (interface_attributes_h[:ip6] == 'dhcp') ? '1' : '0'
    interface_attributes_h[:ip6] = '' if interface_attributes_h[:dhcp6] == '1'
Severity: Minor
Found in app/helpers/proxmox_vm_interfaces_helper.rb - About 25 mins 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 each has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def each(collection_filters = {}, &block)
        if block_given?
          Kernel.loop do
            break unless collection_filters[:marker]

Severity: Minor
Found in app/models/concerns/fog_extensions/proxmox/node.rb - About 25 mins 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_cdrom has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_server_cdrom(args)
    cdrom_media = args['cdrom'] if args.key?('cdrom')
    cdrom_image = args['volid'] if args.key?('volid')
    volid = cdrom_image.empty? ? cdrom_media : cdrom_image
    return {} unless volid
Severity: Minor
Found in app/helpers/proxmox_vm_cdrom_helper.rb - About 25 mins 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 ProxmoxServerOptions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const ProxmoxServerOptions = ({ options }) => {
  const [opts, setOpts] = useState(options);

  const handleChange = e => {
    const { name, type, checked, value: targetValue } = e.target;
Severity: Minor
Found in webpack/components/ProxmoxServer/ProxmoxServerOptions.js - About 25 mins 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 cluster_nodes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def cluster_nodes(compute_resource)
    nodes = compute_resource.nodes ? compute_resource.nodes.collect(&:node) : []
  rescue ::Foreman::Exception => e
    [] if e.message == 'User token expired'
  rescue StandardError => e
Severity: Minor
Found in app/helpers/proxmox_compute_resources_helper.rb - About 25 mins 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