theforeman/foreman_fog_proxmox

View on GitHub

Showing 52 of 52 total issues

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

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 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 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
    return [] 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

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

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

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

    def isos_by_id_and_node_and_storage
      volumes = load_compute_resource(params[:compute_resource_id]).images_by_storage(params[:node_id],
        params[:storage], 'iso')
      respond_to do |format|
        format.json { render :json => volumes }
app/controllers/foreman_fog_proxmox/compute_resources_controller.rb on lines 32..36
app/controllers/foreman_fog_proxmox/compute_resources_controller.rb on lines 41..45

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

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 3 locations. Consider refactoring.
Open

    def isos_by_id_and_node
      volumes = load_compute_resource(params[:compute_resource_id]).images_by_storage(params[:node_id],
        params[:storage], 'iso')
      respond_to do |format|
        format.json { render :json => volumes }
app/controllers/foreman_fog_proxmox/compute_resources_controller.rb on lines 23..27
app/controllers/foreman_fog_proxmox/compute_resources_controller.rb on lines 32..36

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

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 3 locations. Consider refactoring.
Open

    def ostemplates_by_id_and_node_and_storage
      volumes = load_compute_resource(params[:compute_resource_id]).images_by_storage(params[:node_id],
        params[:storage], 'vztmpl')
      respond_to do |format|
        format.json { render :json => volumes }
app/controllers/foreman_fog_proxmox/compute_resources_controller.rb on lines 23..27
app/controllers/foreman_fog_proxmox/compute_resources_controller.rb on lines 41..45

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

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