MissionCriticalCloud/vagrant-cloudstack

View on GitHub

Showing 46 of 50 total issues

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

        def retrieve_public_ip_port(cloudstack, domain_config, machine)
          pf_ip_address_id = domain_config.pf_ip_address_id
          pf_ip_address = domain_config.pf_ip_address
          pf_public_port = domain_config.send(@public_port_fieldname)

Severity: Minor
Found in lib/vagrant-cloudstack/action/read_transport_info.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 action_up has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def self.action_up
        Vagrant::Action::Builder.new.tap do |b|
          b.use ConfigValidate
          b.use ConnectCloudstack
          b.use Call, IsCreated do |env1, b1|
Severity: Minor
Found in lib/vagrant-cloudstack/action.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 read_ssh_info has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def read_ssh_info(cloudstack, machine)
          return nil if (server = find_server(cloudstack, machine)).nil?

          # Get the Port forwarding config
          domain        = machine.provider_config.domain_id
Severity: Minor
Found in lib/vagrant-cloudstack/action/read_ssh_info.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 action_destroy has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def self.action_destroy
        Vagrant::Action::Builder.new.tap do |b|
          b.use Call, DestroyConfirm do |env, b2|
            if env[:result]
              b2.use ConfigValidate
Severity: Minor
Found in lib/vagrant-cloudstack/action.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 read_winrm_info has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def read_winrm_info(cloudstack, machine)
              return nil if (server = find_server(cloudstack, machine)).nil?
    
              # Get the Port forwarding config
              domain        = machine.provider_config.domain_id
    Severity: Minor
    Found in lib/vagrant-cloudstack/action/read_winrm_info.rb - About 1 hr to fix

      Method finalize! has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def finalize!
              INSTANCE_VAR_DEFAULT_NIL.each do |instance_variable|
                # ... must be nil, since we can't default that
                instance_variable_set("@#{instance_variable}", nil) if
                    instance_variable_get("@#{instance_variable}") == UNSET_VALUE
      Severity: Minor
      Found in lib/vagrant-cloudstack/config.rb - About 1 hr to fix

        Method retrieve_public_ip_port has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def retrieve_public_ip_port(cloudstack, domain_config, machine)
                  pf_ip_address_id = domain_config.pf_ip_address_id
                  pf_ip_address = domain_config.pf_ip_address
                  pf_public_port = domain_config.send(@public_port_fieldname)
        
        
        Severity: Minor
        Found in lib/vagrant-cloudstack/action/read_transport_info.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 remove_security_groups has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                      def remove_security_groups(env)
                        security_groups_file = env[:machine].data_dir.join('security_groups')
                        if security_groups_file.file?
                          File.read(security_groups_file).each_line do |line|
                            security_group_id = line.strip
              Severity: Minor
              Found in lib/vagrant-cloudstack/action/terminate_instance.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

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

                      def wait_for_job_ready(env, job_id, message=nil)
                        while true
                          response = env[:cloudstack_compute].query_async_job_result({:jobid => job_id})
                          if response['queryasyncjobresultresponse']['jobstatus'] != 0
                            break
              Severity: Minor
              Found in lib/vagrant-cloudstack/action/terminate_instance.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

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

                    def self.action_reload
                      Vagrant::Action::Builder.new.tap do |b|
                        b.use ConfigValidate
                        b.use ConnectCloudstack
                        b.use Call, IsCreated do |env, b2|
              Severity: Minor
              Found in lib/vagrant-cloudstack/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

              Method sync_resource has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                      def sync_resource(resource, api_parameters = {})
                        @resource_details = nil
                        if resource.id.nil? and !(resource.name.nil? || resource.name.empty? )
                          resource.id = name_to_id(resource.name, resource.kind, api_parameters)
                        elsif resource.id
              Severity: Minor
              Found in lib/vagrant-cloudstack/service/cloudstack_resource_service.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 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 call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                      def call(env)
                        env[:result] = true
                        if env[:machine].state.id == @state
                          @logger.info(I18n.t("vagrant_cloudstack.already_status", :status => @state))
                        else
              Severity: Minor
              Found in lib/vagrant-cloudstack/action/wait_for_state.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 which has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def which(cmd)
                exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
                ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
                  exts.each { |ext|
                    exe = File.join(path, "#{cmd}#{ext}")
              Severity: Minor
              Found in functional-tests/vmlifecycle/vmlifecycle_spec.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

              Severity
              Category
              Status
              Source
              Language