maestrodev/maestro-rightscale-plugin

View on GitHub

Showing 76 of 122 total issues

Avoid deeply nested control flow statements.
Open

        if !result.errors.nil?
          puts "#{result.errors.size} Errors starting server (id=#{options[:server_id]} name=#{options[:server_name]})"
          result.errors.each{|error|
            puts "  #{error.message}, backtrace=#{error.backtrace}"
          }
Severity: Major
Found in src/rightscale_api_helper.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

            if !result.notices.nil?
              puts "#{result.notices.size} Notices starting server (id=#{options[:server_id]} name=#{options[:server_name]})"
              result.notices.each{|notice|
                puts "  #{notice.inspect}"
              }
    Severity: Major
    Found in src/rightscale_api_helper.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                        if show_progress
                          @logger.info "#{indent}create_cloudflow_process(): Process state is #{state} (#{timeout-timeout_left}/#{timeout})"
                        else
                          @logger.debug "#{indent}create_cloudflow_process(): Process state is #{state} (#{timeout-timeout_left}/#{timeout})"
                        end
      Severity: Major
      Found in src/rightscale_api_helper.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                          if show_progress
                            @logger.info "#{indent}create_cloudflow_process(): Process state is now #{state}"
                          else
                            @logger.debug "#{indent}create_cloudflow_process(): Process state is now #{state}"
                          end
        Severity: Major
        Found in src/rightscale_api_helper.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                elsif options[:operation] == 'stop-server'
                  result = helper.stop(options)
                  if options[:wait_until_stopped]
                    puts "Server (id=#{options[:server_id]} name=#{options[:server_name]}) stopped"
                  else
          Severity: Major
          Found in src/rightscale_api_helper.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                              if timeout_reset
                                timeout_left = timeout
                                reset = true
                              end
            Severity: Major
            Found in src/rightscale_api_helper.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                      if result.success
                        if options[:wait_until_started]
                          puts "Server (id=#{options[:server_id]} name=#{options[:server_name]}) started"
                          instance = result.value
                          puts "  resource_uid: #{instance.resource_uid}"
              Severity: Major
              Found in src/rightscale_api_helper.rb - About 45 mins to fix

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

                      def get_server
                        Maestro.log.info "Retrieving RightScale server information into the Composition"
                  
                        # TODO: much duplication with start, but refactor after other changes for deployments land
                  
                Severity: Minor
                Found in src/right_scale_worker.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 validate_base_fields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                      def validate_base_fields(missing_fields)
                        if get_field('account_id').nil?
                          missing_fields << 'account_id'
                        end
                        if get_field('refresh_token').nil? && get_field('username').nil? && get_field('password').nil?
                Severity: Minor
                Found in src/right_scale_worker.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

                Avoid too many return statements within this method.
                Open

                                  return Result.new(:success => false, :errors => [Exception.new("#{reponse.code} #{response}")])
                Severity: Major
                Found in src/rightscale_api_helper.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return Result.new(:success => true, :value => instance)
                  Severity: Major
                  Found in src/rightscale_api_helper.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                              return Result.new(:success => false, :errors => [e])
                    Severity: Major
                    Found in src/rightscale_api_helper.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                return Result.new(:success => false, :errors => [Exception.new('No refresh token was specified, nor was a username/password/account')])
                      Severity: Major
                      Found in src/rightscale_api_helper.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                          return Result.new(:success => false, :errors => [Exception.new(data['error_description'])], :value => data)
                        Severity: Major
                        Found in src/rightscale_api_helper.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                            return Result.new(:success => false, :errors => [Exception.new(result.to_hash['error_description'])])
                          Severity: Major
                          Found in src/rightscale_api_helper.rb - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return Result.new(:success => false, :errors => [Exception.new(e.response['error_description'])], :value => e.response)
                            Severity: Major
                            Found in src/rightscale_api_helper.rb - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                      return Result.new(:success => true, :value => server)
                              Severity: Major
                              Found in src/rightscale_api_helper.rb - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                          return Result.new(:success => false, :errors => [Exception.new(e.response['error_description'])], :value => e.response)
                                Severity: Major
                                Found in src/rightscale_api_helper.rb - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                    return Result.new(:success => false, :errors => [Exception.new('CloudFlow failed to complete successfully')])
                                  Severity: Major
                                  Found in src/rightscale_api_helper.rb - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                      return Result.new(:success => false, :errors => [Exception.new(response_hash['summary'])])
                                    Severity: Major
                                    Found in src/rightscale_api_helper.rb - About 30 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language