fog/fog-libvirt

View on GitHub

Showing 29 of 29 total issues

Method upload_volume has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def upload_volume(pool_name, volume_name, file_path)
          volume = client.lookup_storage_pool_by_name(pool_name).lookup_volume_by_name(volume_name)
          stream = client.stream

          image_file = File.open(file_path, "rb")
Severity: Minor
Found in lib/fog/libvirt/requests/compute/upload_volume.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 list_interfaces has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def list_interfaces(filter = { })
          data=[]
          if filter.keys.empty?
            active_networks = client.list_interfaces rescue []
            defined_networks = client.list_defined_interfaces rescue []
Severity: Minor
Found in lib/fog/libvirt/requests/compute/list_interfaces.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 2 locations. Consider refactoring.
Open

  def test_addresses_calls_compat_version_for_older_libvirt
    network = Libvirt::Network.new
    @compute.expects(:libversion).returns(1002007)
    @compute.expects(:networks).returns([network])
    network.expects(:dhcp_leases).returns(true)
Severity: Minor
Found in minitests/server/server_test.rb and 1 other location - About 25 mins to fix
minitests/server/server_test.rb on lines 28..35

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

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

Method initialize_volumes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def initialize_volumes
          if attributes[:volumes] && !attributes[:volumes].empty?
            @volumes = attributes[:volumes].map { |vol| vol.is_a?(Hash) ? service.volumes.new(vol) : vol }
          end
        end
Severity: Minor
Found in lib/fog/libvirt/models/compute/server.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 2 locations. Consider refactoring.
Open

  def test_addresses_calls_compat_version_for_newer_libvirt
    network = Libvirt::Network.new
    @compute.expects(:libversion).returns(1002008)
    @compute.expects(:networks).returns([network])
    network.expects(:dhcp_leases).returns(true)
Severity: Minor
Found in minitests/server/server_test.rb and 1 other location - About 25 mins to fix
minitests/server/server_test.rb on lines 18..25

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

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

module Fog
  module Libvirt
    class Compute
      class Interfaces < Fog::Collection
        model Fog::Libvirt::Compute::Interface
Severity: Minor
Found in lib/fog/libvirt/models/compute/interfaces.rb and 3 other locations - About 20 mins to fix
lib/fog/libvirt/models/compute/networks.rb on lines 4..15
lib/fog/libvirt/models/compute/pools.rb on lines 4..15
lib/fog/libvirt/models/compute/volumes.rb on lines 4..15

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

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

module Fog
  module Libvirt
    class Compute
      class Networks < Fog::Collection
        model Fog::Libvirt::Compute::Network
Severity: Minor
Found in lib/fog/libvirt/models/compute/networks.rb and 3 other locations - About 20 mins to fix
lib/fog/libvirt/models/compute/interfaces.rb on lines 4..15
lib/fog/libvirt/models/compute/pools.rb on lines 4..15
lib/fog/libvirt/models/compute/volumes.rb on lines 4..15

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

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

module Fog
  module Libvirt
    class Compute
      class Volumes < Fog::Collection
        model Fog::Libvirt::Compute::Volume
Severity: Minor
Found in lib/fog/libvirt/models/compute/volumes.rb and 3 other locations - About 20 mins to fix
lib/fog/libvirt/models/compute/interfaces.rb on lines 4..15
lib/fog/libvirt/models/compute/networks.rb on lines 4..15
lib/fog/libvirt/models/compute/pools.rb on lines 4..15

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

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

module Fog
  module Libvirt
    class Compute
      class Pools < Fog::Collection
        model Fog::Libvirt::Compute::Pool
Severity: Minor
Found in lib/fog/libvirt/models/compute/pools.rb and 3 other locations - About 20 mins to fix
lib/fog/libvirt/models/compute/interfaces.rb on lines 4..15
lib/fog/libvirt/models/compute/networks.rb on lines 4..15
lib/fog/libvirt/models/compute/volumes.rb on lines 4..15

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

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