MissionCriticalCloud/vagrant-cloudstack

View on GitHub

Showing 50 of 50 total issues

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

      def validate(machine)
        errors = []

        if @domain
          # Get the configuration for the domain we're using and validate only that domain.
Severity: Minor
Found in lib/vagrant-cloudstack/config.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 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 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 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 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 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 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 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 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 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

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

                    def self.action_halt
                      Vagrant::Action::Builder.new.tap do |b|
                        b.use ConfigValidate
                        b.use Call, IsCreated do |env, b2|
                          if !env[:result]
              Severity: Minor
              Found in lib/vagrant-cloudstack/action.rb and 1 other location - About 40 mins to fix
              lib/vagrant-cloudstack/action.rb on lines 48..58

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

              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

                    def self.action_provision
                      Vagrant::Action::Builder.new.tap do |b|
                        b.use ConfigValidate
                        b.use Call, IsCreated do |env, b2|
                          if !env[:result]
              Severity: Minor
              Found in lib/vagrant-cloudstack/action.rb and 1 other location - About 40 mins to fix
              lib/vagrant-cloudstack/action.rb on lines 11..21

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

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

              Severity
              Category
              Status
              Source
              Language