frapposelli/vagrant-vcloud

View on GitHub

Showing 135 of 135 total issues

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

        def shutdown_vm(vm_id)
          builder = Nokogiri::XML::Builder.new do |xml|
            xml.UndeployVAppParams(
            'xmlns' => 'http://www.vmware.com/vcloud/v1.5'
          ) { xml.UndeployPowerAction 'shutdown' }
Severity: Major
Found in lib/vagrant-vcloud/driver/version_5_1.rb and 3 other locations - About 1 hr to fix
lib/vagrant-vcloud/driver/version_5_1.rb on lines 480..498
lib/vagrant-vcloud/driver/version_5_1.rb on lines 577..595
lib/vagrant-vcloud/driver/version_5_1.rb on lines 625..643

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

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

        def poweroff_vapp(vapp_id)
          builder = Nokogiri::XML::Builder.new do |xml|
            xml.UndeployVAppParams(
              'xmlns' => 'http://www.vmware.com/vcloud/v1.5'
            ) { xml.UndeployPowerAction 'powerOff' }
Severity: Major
Found in lib/vagrant-vcloud/driver/version_5_1.rb and 3 other locations - About 1 hr to fix
lib/vagrant-vcloud/driver/version_5_1.rb on lines 577..595
lib/vagrant-vcloud/driver/version_5_1.rb on lines 602..620
lib/vagrant-vcloud/driver/version_5_1.rb on lines 625..643

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

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

        def set_vm_network_config(vm_id, network_name, config = {})
          builder = Nokogiri::XML::Builder.new do |xml|
            xml.NetworkConnectionSection(
              'xmlns' => 'http://www.vmware.com/vcloud/v1.5',
              'xmlns:ovf' => 'http://schemas.dmtf.org/ovf/envelope/1') {
Severity: Minor
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 55 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_edge_gateway_rules has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def add_edge_gateway_rules(edge_gateway_name, vdc_id, edge_gateway_ip, vapp_id, ports)
          edge_vapp_ip = get_vapp_edge_public_ip(vapp_id)
          edge_network_id = find_edge_gateway_network(
            edge_gateway_name,
            vdc_id,
Severity: Minor
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 55 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 set_ovf_properties has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def set_ovf_properties(vm_id, properties)
          params = {
            'method'  => :get,
            'command' => "/vApp/vm-#{vm_id}/productSections"
          }
Severity: Minor
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 55 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 set_vm_guest_customization has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def set_vm_guest_customization(vm_id, computer_name, config = {})
          builder = Nokogiri::XML::Builder.new do |xml|
          xml.GuestCustomizationSection(
            'xmlns' => 'http://www.vmware.com/vcloud/v1.5',
            'xmlns:ovf' => 'http://schemas.dmtf.org/ovf/envelope/1') {
Severity: Minor
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 55 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 initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def initialize(id, host_port, guest_port, network_name, edge_network_id, edge_network_name, options)
Severity: Major
Found in lib/vagrant-vcloud/model/forwarded_port.rb - About 50 mins to fix

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

  module VCloud
    module Action
      class Resume
        def initialize(app, env)
          @app = app
Severity: Minor
Found in lib/vagrant-vcloud/action/resume.rb and 1 other location - About 50 mins to fix
lib/vagrant-vcloud/action/suspend.rb on lines 2..20

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

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

  module VCloud
    module Action
      class Suspend
        def initialize(app, env)
          @app = app
Severity: Minor
Found in lib/vagrant-vcloud/action/suspend.rb and 1 other location - About 50 mins to fix
lib/vagrant-vcloud/action/resume.rb on lines 2..20

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

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 upload_ovf has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def upload_ovf(vdc_id, vapp_name, vapp_description, ovf_file, catalog_id, upload_options = {})
Severity: Minor
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                changed = true if orig_ip.nil? || nic[:ip].upcase != orig_ip.upcase
Severity: Major
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 45 mins to fix

Method action_up has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def self.action_up
        Vagrant::Action::Builder.new.tap do |b|
          b.use ConfigValidate
          b.use Call, IsCreated do |env, b2|
            b2.use HandleBox unless env[:result]
Severity: Minor
Found in lib/vagrant-vcloud/action.rb - About 45 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

Avoid deeply nested control flow statements.
Open

              if hdd_parent_id == item.css('rasd|Parent').first.text
                hdd_address_on_parent = [ hdd_address_on_parent,  item.css('rasd|AddressOnParent').first.text.to_i ].max
              end
Severity: Major
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 45 mins to fix

Method compose_vapp_from_vm has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def compose_vapp_from_vm(vdc, vapp_name, vapp_description, vm_list = {}, network_config = [], _cfg)
Severity: Minor
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 45 mins to fix

Method upload_ovf has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def upload_ovf(vdc_id, vapp_name, vapp_description, ovf_file,
                       catalog_id, upload_options = {})
Severity: Minor
Found in lib/vagrant-vcloud/driver/base.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                item.css('rasd|Address').first.content = nic[:mac] if !nic[:mac].nil?
Severity: Major
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                changed = true if nic[:mac].upcase != orig_mac.upcase
Severity: Major
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                item.css('rasd|AddressOnParent').first.content = nic_address_on_parent if nic_address_on_parent != orig_parent
Severity: Major
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                if nic[:ip_mode].upcase == 'DHCP'
                  conn['vcloud:ipAddressingMode'] = 'DHCP'
                elsif nic[:ip_mode].upcase == 'STATIC'
                  conn['vcloud:ipAddressingMode'] = 'MANUAL'
                  conn['vcloud:ipAddress'] = nic[:ip]
Severity: Major
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

              if hdd_parent_id.nil?
                hdd_parent_id = item.css('rasd|Parent').first.text
                hdd_bus_type = item.css('rasd|HostResource').first[:busType]
                hdd_bus_sub_type = item.css('rasd|HostResource').first[:busSubType]
              end
Severity: Major
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 45 mins to fix
Severity
Category
Status
Source
Language