gosddc/vagrant-vcloudair

View on GitHub

Showing 109 of 109 total issues

Method forward_ports has 74 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def forward_ports
          ports = []
          edge_ports = []

          cfg = @env[:machine].provider_config
Severity: Major
Found in lib/vagrant-vcloudair/action/forward_ports.rb - About 2 hrs to fix

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

        def call(env)
          @logger.info('Detecting any forwarded port collisions...')

          # Determine a list of usable ports for repair
          usable_ports = Set.new(env[:machine].config.vm.usable_port_range)
Severity: Minor
Found in lib/vagrant-vcloudair/action/handle_nat_port_collisions.rb - About 2 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 read_ssh_info has a Cognitive Complexity of 21 (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.vcloudair_cnx.driver
Severity: Minor
Found in lib/vagrant-vcloudair/action/read_ssh_info.rb - About 2 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 vcloud_check_inventory has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

        def vcloud_check_inventory(env)
          # Will check each mandatory config value against the vCloud Air
          # Instance and will setup the global environment config values
          cfg = env[:machine].provider_config
          cnx = cfg.vcloudair_cnx.driver
Severity: Minor
Found in lib/vagrant-vcloudair/action/inventory_check.rb - About 2 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_file has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

        def upload_file(upload_url, upload_file, vapp_template, config = {})
          # Set chunksize to 5M if not specified otherwise
          chunk_size = (config[:chunksize] || 5_242_880)
          @logger.debug("Set chunksize to #{chunk_size} bytes")

Severity: Minor
Found in lib/vagrant-vcloudair/driver/base.rb - About 2 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 a Cognitive Complexity of 19 (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-vcloudair/driver/version_5_1.rb - About 2 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 initialize has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

        def initialize(cloud_id, username, password, vdc_name)
          # Setup the base
          super()

          @username = username
Severity: Minor
Found in lib/vagrant-vcloudair/driver/meta.rb - About 2 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 send_vcloudair_request has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

          def send_vcloudair_request(params, payload = nil, content_type = nil)
            # Create a new HTTP client
            clnt = HTTPClient.new

            # Disable SSL cert verification
Severity: Major
Found in lib/vagrant-vcloudair/driver/base.rb - About 2 hrs to fix

Method execute has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def execute
        options = {}
        opts = OptionParser.new do |o|
          o.banner = 'Usage: vagrant vcloud [options]'

Severity: Major
Found in lib/vagrant-vcloudair/command.rb - About 2 hrs to fix

Method send_request has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def send_request(params, payload = nil, content_type = nil)
          # Create a new HTTP client
          clnt = HTTPClient.new

          # Set SSL proto to TLSv1
Severity: Major
Found in lib/vagrant-vcloudair/driver/base.rb - About 2 hrs to fix

Method validate has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def validate(machine)
        errors = _detected_errors

        errors << I18n.t('vagrant_vcloudair.errors.config.username') if username.nil?
        errors << I18n.t('vagrant_vcloudair.errors.config.password') if password.nil?
Severity: Major
Found in lib/vagrant-vcloudair/config.rb - About 2 hrs to fix

File action.rb has 255 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'pathname'
require 'vagrant/action/builder'

module VagrantPlugins
  module VCloudAir
Severity: Minor
Found in lib/vagrant-vcloudair/action.rb - About 2 hrs to fix

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 {
                  xml.NetworkConnectionSection(
Severity: Major
Found in lib/vagrant-vcloudair/driver/version_5_1.rb and 1 other location - About 2 hrs to fix
lib/vagrant-vcloudair/driver/version_5_1.rb on lines 849..866

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

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 {
                  xml.NetworkConnectionSection(
Severity: Major
Found in lib/vagrant-vcloudair/driver/version_5_1.rb and 1 other location - About 2 hrs to fix
lib/vagrant-vcloudair/driver/version_5_1.rb on lines 786..803

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

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

          def send_vcloudair_request(params, payload = nil, content_type = nil)
            # Create a new HTTP client
            clnt = HTTPClient.new

            # Disable SSL cert verification
Severity: Minor
Found in lib/vagrant-vcloudair/driver/base.rb - About 2 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 get_vm has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

Method get_edge_gateway_rules has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def get_edge_gateway_rules(edge_gateway_name, vdc_id)
          edge_gateway_id = find_edge_gateway_id(edge_gateway_name, vdc_id)

          params = {
            'method'  => :get,
Severity: Minor
Found in lib/vagrant-vcloudair/driver/version_5_1.rb - About 2 hrs to fix

Method send_request has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

        def send_request(params, payload = nil, content_type = nil)
          # Create a new HTTP client
          clnt = HTTPClient.new

          # Set SSL proto to TLSv1
Severity: Minor
Found in lib/vagrant-vcloudair/driver/base.rb - About 1 hr 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 remove_edge_gateway_rules has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def remove_edge_gateway_rules(edge_gateway_name, vdc_id, edge_gateway_ip, vapp_id)
          edge_vapp_ip = get_vapp_edge_public_ip(vapp_id)
          edge_gateway_id = find_edge_gateway_id(edge_gateway_name, vdc_id)

          params = {
Severity: Minor
Found in lib/vagrant-vcloudair/driver/version_5_1.rb - About 1 hr to fix

Method recompose_vapp_from_vm has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

          builder = Nokogiri::XML::Builder.new do |xml|
          xml.RecomposeVAppParams(
Severity: Minor
Found in lib/vagrant-vcloudair/driver/version_5_1.rb - About 1 hr to fix
Severity
Category
Status
Source
Language