frapposelli/vagrant-vcloud

View on GitHub

Showing 135 of 135 total issues

File version_5_1.rb has 1766 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'ruby-progressbar'
require 'set'
require 'netaddr'
require 'uri'

Severity: Major
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 4 days to fix

Method compose_vapp_from_vm has a Cognitive Complexity of 167 (exceeds 5 allowed). Consider refactoring.
Open

        def compose_vapp_from_vm(vdc, vapp_name, vapp_description, vm_list = {}, network_config = [], _cfg)
          builder = Nokogiri::XML::Builder.new do |xml|
            xml.ComposeVAppParams('xmlns' => 'http://www.vmware.com/vcloud/v1.5',
                                  'xmlns:ovf' => 'http://schemas.dmtf.org/ovf/envelope/1',
                                  'deploy' => 'false',
Severity: Minor
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 3 days 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_hardware has a Cognitive Complexity of 101 (exceeds 5 allowed). Consider refactoring.
Open

        def set_vm_hardware(vm_id, cfg)
          params = {
            'method'  => :get,
            'command' => "/vApp/vm-#{vm_id}/virtualHardwareSection"
          }
Severity: Minor
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 2 days 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 recompose_vapp_from_vm has a Cognitive Complexity of 100 (exceeds 5 allowed). Consider refactoring.
Open

        def recompose_vapp_from_vm(vapp_id, vm_list = {}, network_config = [], _cfg)
          original_vapp = get_vapp(vapp_id)

          builder = Nokogiri::XML::Builder.new do |xml|
          xml.RecomposeVAppParams(
Severity: Minor
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 2 days 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 call has a Cognitive Complexity of 90 (exceeds 5 allowed). Consider refactoring.
Open

        def call(env)
          # FIXME: we need to find a way to clean things up when a SIGINT get
          # called... see env[:interrupted] in the vagrant code

          cfg = env[:machine].provider_config
Severity: Minor
Found in lib/vagrant-vcloud/action/build_vapp.rb - About 1 day 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 call has 243 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def call(env)
          # FIXME: we need to find a way to clean things up when a SIGINT get
          # called... see env[:interrupted] in the vagrant code

          cfg = env[:machine].provider_config
Severity: Major
Found in lib/vagrant-vcloud/action/build_vapp.rb - About 1 day to fix

Class Version_5_1 has 58 methods (exceeds 20 allowed). Consider refactoring.
Open

      class Version_5_1 < Base
        attr_reader :auth_key, :id

        ##
        # Init the driver with the Vagrantfile information
Severity: Major
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 1 day to fix

Method validate has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

      def validate(machine)
        errors = _detected_errors

        # TODO: add blank?
        errors << I18n.t('vagrant_vcloud.config.hostname') if hostname.nil?
Severity: Minor
Found in lib/vagrant-vcloud/config.rb - About 7 hrs 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

              vm_list.each do |vm_name, vm_id|
                xml.SourcedItem {
                  xml.Source('href' => "#{@api_url}/vAppTemplate/vm-#{vm_id}", 'name' => vm_name)
                  xml.InstantiationParams {
                    if _cfg.enable_guest_customization.nil? || _cfg.enable_guest_customization
Severity: Major
Found in lib/vagrant-vcloud/driver/version_5_1.rb and 1 other location - About 7 hrs to fix
lib/vagrant-vcloud/driver/version_5_1.rb on lines 935..987

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

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

            vm_list.each do |vm_name, vm_id|
                xml.SourcedItem {
                  xml.Source('href' => "#{@api_url}/vAppTemplate/vm-#{vm_id}", 'name' => vm_name)
                  xml.InstantiationParams {
                    if _cfg.enable_guest_customization.nil? || _cfg.enable_guest_customization
Severity: Major
Found in lib/vagrant-vcloud/driver/version_5_1.rb and 1 other location - About 7 hrs to fix
lib/vagrant-vcloud/driver/version_5_1.rb on lines 838..890

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

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

        def compile_forwarded_ports(machine)
          mappings = {}

          machine.config.vm.networks.each do |type, options|
            if type == :forwarded_port
Severity: Minor
Found in lib/vagrant-vcloud/util/compile_forwarded_ports.rb - About 6 hrs 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_hardware has 161 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def set_vm_hardware(vm_id, cfg)
          params = {
            'method'  => :get,
            'command' => "/vApp/vm-#{vm_id}/virtualHardwareSection"
          }
Severity: Major
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 6 hrs to fix

Method read_ssh_info has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

        def read_ssh_info(env)
          return nil if env[:machine].id.nil?

          cfg = env[:machine].provider_config
          cnx = cfg.vcloud_cnx.driver
Severity: Minor
Found in lib/vagrant-vcloud/action/read_ssh_info.rb - About 6 hrs 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 upload_ovf has 132 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def upload_ovf(vdc_id, vapp_name, vapp_description, ovf_file, catalog_id, upload_options = {})
          # if send_manifest is not set, setting it true
          if upload_options[:send_manifest].nil? ||
             upload_options[:send_manifest]
            upload_manifest = 'true'
Severity: Major
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 5 hrs to fix

Method compose_vapp_from_vm has 131 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def compose_vapp_from_vm(vdc, vapp_name, vapp_description, vm_list = {}, network_config = [], _cfg)
          builder = Nokogiri::XML::Builder.new do |xml|
            xml.ComposeVAppParams('xmlns' => 'http://www.vmware.com/vcloud/v1.5',
                                  'xmlns:ovf' => 'http://schemas.dmtf.org/ovf/envelope/1',
                                  'deploy' => 'false',
Severity: Major
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 5 hrs to fix

Class Base has 38 methods (exceeds 20 allowed). Consider refactoring.
Open

      class Base
        include Vagrant::Util::Retryable

        def initialize
          @logger = Log4r::Logger.new('vagrant::provider::vcloud::base')
Severity: Minor
Found in lib/vagrant-vcloud/driver/base.rb - About 5 hrs to fix

Method add_edge_gateway_rules has 108 lines of code (exceeds 25 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: Major
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 4 hrs to fix

Method call has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

        def call(env)
          @env = env

          cfg = env[:machine].provider_config
          cnx = cfg.vcloud_cnx.driver
Severity: Minor
Found in lib/vagrant-vcloud/action/power_on.rb - About 4 hrs 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 command_vcloud_network has 98 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def command_vcloud_network(cfg, vapp_id, ssh_host)
        # FIXME: this needs to be fixed to accomodate the bridged scenario
        # potentially showing only the assigned IPs in the VMs

        puts 'Fetching vCloud Director network settings ...'
Severity: Major
Found in lib/vagrant-vcloud/command.rb - About 3 hrs to fix

Method command_vcloud_network has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

      def command_vcloud_network(cfg, vapp_id, ssh_host)
        # FIXME: this needs to be fixed to accomodate the bridged scenario
        # potentially showing only the assigned IPs in the VMs

        puts 'Fetching vCloud Director network settings ...'
Severity: Minor
Found in lib/vagrant-vcloud/command.rb - About 3 hrs 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