MissionCriticalCloud/vagrant-cloudstack

View on GitHub
lib/vagrant-cloudstack/action/run_instance.rb

Summary

Maintainability
F
5 days
Test Coverage

File run_instance.rb has 722 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'log4r'
require 'vagrant/util/retryable'
require 'vagrant-cloudstack/exceptions/exceptions'
require 'vagrant-cloudstack/util/timer'
require 'vagrant-cloudstack/model/cloudstack_resource'
Severity: Major
Found in lib/vagrant-cloudstack/action/run_instance.rb - About 1 day to fix

    Class RunInstance has 49 methods (exceeds 20 allowed). Consider refactoring.
    Open

          class RunInstance
            include Vagrant::Util::Retryable
            include VagrantPlugins::Cloudstack::Model
            include VagrantPlugins::Cloudstack::Service
            include VagrantPlugins::Cloudstack::Exceptions
    Severity: Minor
    Found in lib/vagrant-cloudstack/action/run_instance.rb - About 6 hrs to fix

      Method compose_server_creation_options has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

              def compose_server_creation_options
                options = {
                    :display_name => @domain_config.display_name,
                    :group => @domain_config.group,
                    :zone_id => @zone.id,
      Severity: Minor
      Found in lib/vagrant-cloudstack/action/run_instance.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 apply_port_forwarding_rules has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

              def apply_port_forwarding_rules
                return if @domain_config.port_forwarding_rules.empty?
      
                @domain_config.port_forwarding_rules.each do |port_forwarding_rule|
                  # Sanatize/defaults pf rule before applying
      Severity: Minor
      Found in lib/vagrant-cloudstack/action/run_instance.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 generate_firewall_rules_for_communicators has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

              def generate_firewall_rules_for_communicators
      
                return if @pf_ip_address.is_undefined? ||
                    !@domain_config.pf_trusted_networks ||
                    @domain_config.pf_open_firewall
      Severity: Minor
      Found in lib/vagrant-cloudstack/action/run_instance.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 create_randomport_forwarding_rule has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

              def create_randomport_forwarding_rule(rule, randomrange, filename)
                pf_public_port = rule[:publicport]
                retryable(:on => DuplicatePFRule, :tries => 10) do
                  begin
                    # Only if public port is missing, will generate a random one
      Severity: Minor
      Found in lib/vagrant-cloudstack/action/run_instance.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 generate_firewall_rules_for_portforwarding_rules has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

              def generate_firewall_rules_for_portforwarding_rules
                @pf_ip_address.details.has_key?('vpcid') ? port_name = :privateport : port_name = :publicport
      
                unless @domain_config.port_forwarding_rules.empty?
                  @domain_config.port_forwarding_rules.each do |port_forwarding_rule|
      Severity: Minor
      Found in lib/vagrant-cloudstack/action/run_instance.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 apply_firewall_rule has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              def apply_firewall_rule(acl_name, options, response_string, type_string)
                firewall_rule = nil
                begin
                  resp = @env[:cloudstack_compute].request(options)
                  job_id = resp[response_string]['jobid']
      Severity: Minor
      Found in lib/vagrant-cloudstack/action/run_instance.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 store_password has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              def store_password
                password = nil
                if @server.password_enabled and @server.respond_to?('job_id')
                  server_job_result = @env[:cloudstack_compute].query_async_job_result({:jobid => @server_job_id})
                  if server_job_result.nil?
      Severity: Minor
      Found in lib/vagrant-cloudstack/action/run_instance.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 wait_for_communicator_ready has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

              def wait_for_communicator_ready
                @env[:metrics]['instance_ssh_time'] = Util::Timer.time do
                  # Wait for communicator to be ready.
                  communicator_short_name = get_communicator_short_name(@env[:machine].communicate)
                  @env[:ui].info(
      Severity: Minor
      Found in lib/vagrant-cloudstack/action/run_instance.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 auto_complete_firewall_rules has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

              def auto_complete_firewall_rules
                @domain_config.firewall_rules.each do |firewall_rule|
                  firewall_rule[:ipaddressid] = @domain_config.pf_ip_address_id if firewall_rule[:ipaddressid].nil?
                  firewall_rule[:ipaddress] = @domain_config.pf_ip_address if firewall_rule[:ipaddress].nil?
                  firewall_rule[:cidrlist] = @domain_config.pf_trusted_networks.join(',') if firewall_rule[:cidrlist].nil?
      Severity: Minor
      Found in lib/vagrant-cloudstack/action/run_instance.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 apply_firewall_rule has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def apply_firewall_rule(acl_name, options, response_string, type_string)
                firewall_rule = nil
                begin
                  resp = @env[:cloudstack_compute].request(options)
                  job_id = resp[response_string]['jobid']
      Severity: Minor
      Found in lib/vagrant-cloudstack/action/run_instance.rb - About 1 hr to fix

        Method create_firewall_rule has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def create_firewall_rule(rule)
                  acl_name = ''
                  firewall_rule = nil
                  @env[:ui].info(I18n.t('vagrant_cloudstack.creating_firewall_rule'))
        
        
        Severity: Minor
        Found in lib/vagrant-cloudstack/action/run_instance.rb - About 1 hr to fix

          Method enable_static_nat has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def enable_static_nat(rule)
                    @env[:ui].info(I18n.t('vagrant_cloudstack.enabling_static_nat'))
          
                    begin
                      ip_address = sync_ip_address(rule[:ipaddressid], rule[:ipaddress])
          Severity: Minor
          Found in lib/vagrant-cloudstack/action/run_instance.rb - About 1 hr to fix

            Method apply_port_forwarding_rule has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                    def apply_port_forwarding_rule(rule)
                      port_forwarding_rule = nil
                      @env[:ui].info(I18n.t('vagrant_cloudstack.creating_port_forwarding_rule'))
            
                      return unless (options = compose_port_forwarding_rule_creation_options(rule))
            Severity: Minor
            Found in lib/vagrant-cloudstack/action/run_instance.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 show_creation_summary has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                    def show_creation_summary
                      # Launch!
                      @env[:ui].info(I18n.t('vagrant_cloudstack.launching_instance'))
                      @env[:ui].info(" -- Display Name: #{@domain_config.display_name}")
                      @env[:ui].info(" -- Group: #{@domain_config.group}") if @domain_config.group
            Severity: Minor
            Found in lib/vagrant-cloudstack/action/run_instance.rb - About 35 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 create_firewall_rule has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def create_firewall_rule(rule)
                      acl_name = ''
                      firewall_rule = nil
                      @env[:ui].info(I18n.t('vagrant_cloudstack.creating_firewall_rule'))
            
            
            Severity: Minor
            Found in lib/vagrant-cloudstack/action/run_instance.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 sanitize_domain_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def sanitize_domain_config
                      # Accept a single entry as input, convert it to array
                      @domain_config.pf_trusted_networks = [@domain_config.pf_trusted_networks] if @domain_config.pf_trusted_networks
            
                      if @domain_config.network_id.nil?
            Severity: Minor
            Found in lib/vagrant-cloudstack/action/run_instance.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 resolve_network has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def resolve_network(cs_zone)
                      if cs_zone.network_type.downcase == 'basic'
                        # No network specification in basic zone
                        @env[:ui].warn(I18n.t('vagrant_cloudstack.basic_network', :zone_name => @zone.name)) if !@networks.empty? && (@networks[0].id || @networks[0].name)
                        @networks = [CloudstackResource.new(nil, nil, 'network')]
            Severity: Minor
            Found in lib/vagrant-cloudstack/action/run_instance.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 generate_and_apply_port_forwarding_rules_for_communicators has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def generate_and_apply_port_forwarding_rules_for_communicators
                      communicators_port_names = [Hash[:public_port => 'pf_public_port', :private_port => 'pf_private_port']]
                      communicators_port_names << Hash[:public_port => 'pf_public_rdp_port', :private_port => 'pf_private_rdp_port'] if is_windows_guest
            
                      communicators_port_names.each do |communicator_port_names|
            Severity: Minor
            Found in lib/vagrant-cloudstack/action/run_instance.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 wait_for_instance_ready has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def wait_for_instance_ready
                      @env[:metrics]['instance_ready_time'] = Util::Timer.time do
                        tries = @domain_config.instance_ready_timeout / 2
            
                        @env[:ui].info(I18n.t('vagrant_cloudstack.waiting_for_ready'))
            Severity: Minor
            Found in lib/vagrant-cloudstack/action/run_instance.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 evaluate_pf_private_port has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def evaluate_pf_private_port
                      return unless @domain_config.pf_private_port.nil?
            
                      communicator_short_name = get_communicator_short_name(@env[:machine].communicate)
                      communicator_config = @env[:machine].config.send(communicator_short_name)
            Severity: Minor
            Found in lib/vagrant-cloudstack/action/run_instance.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

            There are no issues that match your filters.

            Category
            Status