maestrodev/maestro-rightscale-plugin

View on GitHub

Showing 122 of 122 total issues

File rightscale_api_helper.rb has 1278 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'right_api_client'
require 'rubygems'
require 'logger'
require 'optparse'
require 'open-uri'
Severity: Major
Found in src/rightscale_api_helper.rb - About 3 days to fix

    File right_scale_worker.rb has 652 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'maestro_plugin'
    require 'rubygems'  # Unsure why this is required
    require 'rightscale_api_helper'
    
    module MaestroDev
    Severity: Major
    Found in src/right_scale_worker.rb - About 1 day to fix

      Method create_cloudflow_process has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
      Open

            def create_cloudflow_process(args)
              # for convenience
              cloudflow_name = args[:cloudflow_name]
              cloudflow_inputs = args[:cloudflow_inputs]
              cloudflow_definition = args[:cloudflow_definition]
      Severity: Minor
      Found in src/rightscale_api_helper.rb - About 1 day 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

              if wait_until_stopped
                timeout_left = timeout
                start_time = Time.now.to_i
        
                # waiting for each server in the deployment that we just stopped or we're actively trying to shut down
      Severity: Major
      Found in src/rightscale_api_helper.rb and 1 other location - About 6 hrs to fix
      src/rightscale_api_helper.rb on lines 657..701

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

      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

              if wait_until_started
                timeout_left = timeout
                start_time = Time.now.to_i
        
                # waiting for each server in the deployment
      Severity: Major
      Found in src/rightscale_api_helper.rb and 1 other location - About 6 hrs to fix
      src/rightscale_api_helper.rb on lines 775..819

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

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

            def create_cloudflow_process(args)
              # for convenience
              cloudflow_name = args[:cloudflow_name]
              cloudflow_inputs = args[:cloudflow_inputs]
              cloudflow_definition = args[:cloudflow_definition]
      Severity: Major
      Found in src/rightscale_api_helper.rb - About 6 hrs to fix

        Method get_access_token has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

              def get_access_token(args)
                api_url = args[:api_url] || DEFAULT_API_URL
                oauth_url = args[:oauth_url] || DEFAULT_OAUTH_URL
                refresh_token = args[:refresh_token]
                email = args[:email]
        Severity: Minor
        Found in src/rightscale_api_helper.rb - About 4 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 stop_servers_in_deployment has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

              def stop_servers_in_deployment(args)
                # for convenience
                deployment_id = args[:deployment_id]
                deployment_name = args[:deployment_name]
                wait_until_stopped = args[:wait_until_stopped]
        Severity: Minor
        Found in src/rightscale_api_helper.rb - About 3 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 get_access_token has 89 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def get_access_token(args)
                api_url = args[:api_url] || DEFAULT_API_URL
                oauth_url = args[:oauth_url] || DEFAULT_OAUTH_URL
                refresh_token = args[:refresh_token]
                email = args[:email]
        Severity: Major
        Found in src/rightscale_api_helper.rb - About 3 hrs to fix

          Method start_servers_in_deployment has 86 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def start_servers_in_deployment(args)
                  # for convenience
                  deployment_id = args[:deployment_id]
                  deployment_name = args[:deployment_name]
                  wait_until_started = args[:wait_until_started]
          Severity: Major
          Found in src/rightscale_api_helper.rb - About 3 hrs to fix

            Method wait has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                  def wait(args)
                    # for readability
                    server_id = args[:server_id]
                    server_name = args[:server_name]
                    deployment_id = args[:deployment_id]
            Severity: Minor
            Found in src/rightscale_api_helper.rb - About 3 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 start_servers_in_deployment has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

                  def start_servers_in_deployment(args)
                    # for convenience
                    deployment_id = args[:deployment_id]
                    deployment_name = args[:deployment_name]
                    wait_until_started = args[:wait_until_started]
            Severity: Minor
            Found in src/rightscale_api_helper.rb - About 3 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 get_server has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

                  def get_server(args)
                    # for convenience
                    server_id = args[:server_id]
                    server_name = args[:server_name]
                    deployment_id = args[:deployment_id]
            Severity: Minor
            Found in src/rightscale_api_helper.rb - About 3 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 stop_servers_in_deployment has 81 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def stop_servers_in_deployment(args)
                    # for convenience
                    deployment_id = args[:deployment_id]
                    deployment_name = args[:deployment_name]
                    wait_until_stopped = args[:wait_until_stopped]
            Severity: Major
            Found in src/rightscale_api_helper.rb - About 3 hrs to fix

              Method start has 77 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def start
                      Maestro.log.info "Starting RightScale Worker"
                
                      # make sure we have all the necessary fields
                      validate_server_fields()
              Severity: Major
              Found in src/right_scale_worker.rb - About 3 hrs to fix

                Method get_server has 74 lines of code (exceeds 25 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: Major
                Found in src/right_scale_worker.rb - About 2 hrs to fix

                  Method wait has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def wait(args)
                          # for readability
                          server_id = args[:server_id]
                          server_name = args[:server_name]
                          deployment_id = args[:deployment_id]
                  Severity: Major
                  Found in src/rightscale_api_helper.rb - About 2 hrs to fix

                    Method start_deployment has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def start_deployment
                            Maestro.log.info "Starting RightScale Deployment"
                      
                            deployment_id = get_field('deployment_id')
                            deployment_name = get_field('deployment_name')
                    Severity: Major
                    Found in src/right_scale_worker.rb - About 2 hrs to fix

                      Method start has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def start(args)
                              # for readability
                              server_id = args[:server_id]
                              server_name = args[:server_name]
                              deployment_id = args[:deployment_id]
                      Severity: Major
                      Found in src/rightscale_api_helper.rb - About 2 hrs to fix

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

                                        if response_hash && response_hash.is_a?(Hash) && response_hash.has_key?('summary')
                                          @logger.error "#{indent}create_cloudflow_process(): Error creating CloudFlow process: summary: #{response_hash['summary']}"
                                          return Result.new(:success => false, :errors => [Exception.new(response_hash['summary'])])
                                        elsif result.to_hash.has_key?('create_cloudflow_process')
                                          @logger.error "#{indent}create_cloudflow_process(): Error creating CloudFlow process: error_description: #{result.to_hash['error_description']}"
                        Severity: Major
                        Found in src/rightscale_api_helper.rb and 1 other location - About 2 hrs to fix
                        src/rightscale_api_helper.rb on lines 1113..1122

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

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language