frapposelli/vagrant-vcloud

View on GitHub

Showing 135 of 135 total issues

File build_vapp.rb has 260 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'securerandom'
require 'etc'
require 'netaddr'

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

File base.rb has 256 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'log4r'
require 'vagrant/util/busy'
require 'vagrant/util/platform'
require 'vagrant/util/retryable'
require 'vagrant/util/subprocess'
Severity: Minor
Found in lib/vagrant-vcloud/driver/base.rb - About 2 hrs to fix

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

        def call(env)
          @env = env

          cfg = env[:machine].provider_config
          cnx = cfg.vcloud_cnx.driver
Severity: Major
Found in lib/vagrant-vcloud/action/power_on.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-vcloud/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-vcloud/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-vcloud/driver/version_5_1.rb - About 1 hr to fix

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

        def get_vapp_port_forwarding_rules(vapp_id, network_name=nil)
          params = {
            'method'  => :get,
            'command' => "/vApp/vapp-#{vapp_id}/networkConfigSection"
          }
Severity: Minor
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 1 hr to fix

Method get_vapp_port_forwarding_rules has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

        def get_vapp_port_forwarding_rules(vapp_id, network_name=nil)
          params = {
            'method'  => :get,
            'command' => "/vApp/vapp-#{vapp_id}/networkConfigSection"
          }
Severity: Minor
Found in lib/vagrant-vcloud/driver/version_5_1.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 compile_forwarded_ports has 43 lines of code (exceeds 25 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 1 hr to fix

Method get_organization has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def get_organization(org_id)
          params = {
            'method'  => :get,
            'command' => "/org/#{org_id}"
          }
Severity: Minor
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 1 hr to fix

Method set_vapp_port_forwarding_rules has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def set_vapp_port_forwarding_rules(vapp_id, network_name, config = {})
          builder = Nokogiri::XML::Builder.new do |xml|
          xml.NetworkConfigSection(
            '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 1 hr to fix

Method get_vm has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

Method get_vapp_edge_public_ip has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def get_vapp_edge_public_ip(vapp_id, network_name=nil)
          return @cached_vapp_edge_public_ips["#{vapp_id}#{network_name}"] unless @cached_vapp_edge_public_ips["#{vapp_id}#{network_name}"].nil?

          # Check the network configuration section
          params = {
Severity: Minor
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 1 hr to fix

Method vcloud_upload_box has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def vcloud_upload_box(env)
          cfg = env[:machine].provider_config
          cnx = cfg.vcloud_cnx.driver

          box_dir = env[:machine].box.directory.to_s
Severity: Minor
Found in lib/vagrant-vcloud/action/inventory_check.rb - About 1 hr to fix

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

  module VCloud
    module Action
      class PowerOff
        def initialize(app, env)
          @app = app
Severity: Major
Found in lib/vagrant-vcloud/action/power_off.rb and 1 other location - About 1 hr to fix
lib/vagrant-vcloud/action/shut_down.rb on lines 2..28

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

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 ShutDown
        def initialize(app, env)
          @app = app
Severity: Major
Found in lib/vagrant-vcloud/action/shut_down.rb and 1 other location - About 1 hr to fix
lib/vagrant-vcloud/action/power_off.rb on lines 2..28

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

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 get_vapp has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def get_vapp(vapp_id)
          params = {
            'method'  => :get,
            'command' => "/vApp/vapp-#{vapp_id}"
          }
Severity: Minor
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 1 hr to fix

Method find_edge_gateway_network has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def find_edge_gateway_network(edge_gateway_name, vdc_id, edge_gateway_ip)
          params = {
            'method'  => :get,
            'command' => '/query?type=edgeGateway&' \
                         'format=records&' \
Severity: Minor
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 1 hr to fix

Method set_metadata has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def set_metadata(link, data)
          params = {
            'method'  => :post,
            'command' => "/#{link}/metadata"
          }
Severity: Minor
Found in lib/vagrant-vcloud/driver/version_5_1.rb - About 1 hr to fix

Method call has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def call(env)
          cfg = env[:machine].provider_config
          cnx = cfg.vcloud_cnx.driver
          vapp_id = env[:machine].get_vapp_id

Severity: Minor
Found in lib/vagrant-vcloud/action/destroy_vapp.rb - About 1 hr to fix
Severity
Category
Status
Source
Language