aws/aws-codedeploy-agent

View on GitHub

Showing 62 of 87 total issues

Method execute_script has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def execute_script(script, script_log_file)
          script_command = InstanceAgent::Platform.util.prepare_script_command(script, script_absolute_path(script))
          log_script("Script - " + script.location + "\n", script_log_file)
          exit_status = 1
          signal = nil
Severity: Minor
Found in lib/instance_agent/plugins/codedeploy/hook_executor.rb - About 1 hr to fix

    Method unpack_bundle has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

            def unpack_bundle(cmd, bundle_file, deployment_spec)
              dst = File.join(deployment_root_dir(deployment_spec), 'deployment-archive')
    
              if "tar".eql? deployment_spec.bundle_type
                InstanceAgent::Platform.util.extract_tar(bundle_file, dst)
    Severity: Minor
    Found in lib/instance_agent/plugins/codedeploy/command_executor.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_instructions has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def generate_instructions(application_specification)
              InstanceAgent::Plugins::CodeDeployPlugin::InstallInstruction.generate_instructions() do |i|
                application_specification.files.each do |fi|
                  absolute_source_path = File.join(deployment_archive_dir, fi.source)
                  file_exists_behavior = application_specification.respond_to?(:file_exists_behavior) && application_specification.file_exists_behavior ? application_specification.file_exists_behavior : @file_exists_behavior
    Severity: Minor
    Found in lib/instance_agent/plugins/codedeploy/installer.rb - About 1 hr to fix

      Method initialize has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                def initialize(mode)
                  mode = mode.to_s
                  while mode.length < 3 do
                    mode = "0" + mode;
                  end

        Method run has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def run
                start_time = Time.now
        
                begin
                  perform
        Severity: Minor
        Found in lib/instance_agent/agent/base.rb - About 1 hr to fix

          Method stop has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def stop
                  if (pid = self.class.find_pid)
                    puts "Checking first if a deployment is already in progress"
                    ProcessManager::Log.info("Checking first if any deployment lifecycle event is in progress #{description(pid)}")
                    begin
          Severity: Minor
          Found in lib/instance_agent/runner/master.rb - About 1 hr to fix

            Method get_full_acl has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                    def get_full_acl()
                      perm = "%o" % File.stat(@object).mode
                      perm = perm[-3,3]
                      @acl.add_ace(":#{perm[0]}")
                      @acl.add_ace("g::#{perm[1]}")
            Severity: Minor
            Found in lib/instance_agent/plugins/codedeploy/install_instruction.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 configure has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def self.configure
                      file_path = InstanceAgent::Config.config[:on_premises_config_file]
                      file_config = nil
                      if File.exists?(file_path) && File.readable?(file_path)
                        begin
            Severity: Minor
            Found in lib/instance_agent/plugins/codedeploy/onpremise_config.rb - About 1 hr to fix

              Method execute has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      def execute
                        return if @app_spec.nil?
                        if (hooks = @app_spec.hooks[@lifecycle_event]) &&
                        !hooks.empty?
                          create_script_log_file_if_needed do |script_log_file|
              Severity: Minor
              Found in lib/instance_agent/plugins/codedeploy/hook_executor.rb - About 1 hr to fix

                Method process_command has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        def process_command(command, spec)
                          log(:debug, "Calling #{@plugin.to_s}.execute_command")
                          begin
                            deployment_id = InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(spec).deployment_id
                            DeploymentCommandTracker.create_ongoing_deployment_tracking_file(deployment_id, command.host_command_identifier)
                Severity: Minor
                Found in lib/instance_agent/plugins/codedeploy/command_poller.rb - About 1 hr to fix

                  Method initialize has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          def initialize(arguments = {})
                            #check arguments
                            raise "Lifecycle Event Required " if arguments[:lifecycle_event].nil?
                            raise "Deployment ID required " if arguments[:deployment_id].nil?
                            raise "Deployment Root Directory Required " if arguments[:deployment_root_dir].nil?
                  Severity: Minor
                  Found in lib/instance_agent/plugins/codedeploy/hook_executor.rb - About 1 hr to fix

                    Method download_from_s3 has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            def download_from_s3(deployment_spec, bucket, key, version, etag)
                              log(:info, "Downloading artifact bundle from bucket '#{bucket}' and key '#{key}', version '#{version}', etag '#{etag}'")
                              options = s3_options()
                              s3 = Aws::S3::Client.new(options)
                    
                    
                    Severity: Minor
                    Found in lib/instance_agent/plugins/codedeploy/command_executor.rb - About 1 hr to fix

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

                                def parse_permissions(permissions_list)
                                  permissions = []
                                  #loop through list and create permissionsInfo representations
                                  permissions_list.each do |permission|
                                    if !permission.has_key?('object') || permission['object'].nil?

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

                              def initialize(arguments = {})
                                #check arguments
                                raise "Lifecycle Event Required " if arguments[:lifecycle_event].nil?
                                raise "Deployment ID required " if arguments[:deployment_id].nil?
                                raise "Deployment Root Directory Required " if arguments[:deployment_root_dir].nil?
                      Severity: Minor
                      Found in lib/instance_agent/plugins/codedeploy/hook_executor.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 get_range has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                                def get_range
                                  range = "s" + @low_sensitivity.to_s
                                  if (@low_sensitivity != @high_sensitivity)
                                    range = range + "-s" + @high_sensitivity.to_s
                                  end

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

                            def initialize
                              super
                              @config.update({
                                :program_name => 'codedeploy-agent',
                                :wait_between_spawning_children => 1,
                        Severity: Minor
                        Found in lib/instance_agent/config.rb - About 1 hr to fix

                          Method build_spec has 8 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                  def build_spec(location, bundle_type, deployment_group_id, file_exists_behavior, all_possible_lifecycle_events, deployment_group_name, application_name, appspec_filename)
                          Severity: Major
                          Found in lib/aws/codedeploy/local/deployer.rb - About 1 hr to fix

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

                                    def find_matches(permission)
                                      log(:debug, "Finding matches for #{permission.object}")
                                      matches = []
                                      if permission.type.include?("file")
                                        @copy_targets.keys.each do |object|
                            Severity: Minor
                            Found in lib/instance_agent/plugins/codedeploy/install_instruction.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 kill_children has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                                  def kill_children(sig)
                                    children.each do |index, child_pid|
                                      begin
                                        Process.kill(sig, child_pid)
                                      rescue Errno::ESRCH
                            Severity: Minor
                            Found in lib/instance_agent/runner/master.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 next_command has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                                    def next_command
                                      log(:debug, "Calling PollHostCommand:")
                                      begin
                                        output = @deploy_control_client.poll_host_command(:host_identifier => @host_identifier)
                                      rescue Exception => e
                            Severity: Minor
                            Found in lib/instance_agent/plugins/codedeploy/command_poller.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

                            Severity
                            Category
                            Status
                            Source
                            Language