aws/aws-codedeploy-agent

View on GitHub

Showing 62 of 87 total issues

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

        def validate_app_spec_hooks(app_spec_location, all_possible_lifecycle_events)
          app_spec = ApplicationSpecification::ApplicationSpecification.parse(File.read(app_spec_location))
          app_spec_filename = File.basename(app_spec_location)
          unless all_possible_lifecycle_events.nil?
            app_spec_hooks_plus_hooks_from_mapping = app_spec.hooks.keys.to_set.merge(@hook_mapping.keys).to_a
Severity: Minor
Found in lib/instance_agent/plugins/codedeploy/command_executor.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 s3_revision has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def s3_revision(location, uri, bundle_type)
          bucket = uri.host
          if (uri.path[0] != '/')
            raise AWS::CodeDeploy::Local::CLIValidator::ValidationError.new("s3 location #{location} not in the expected format of 's3://bucket/key'")
          end
Severity: Minor
Found in lib/aws/codedeploy/local/deployer.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 run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def run
        start_time = Time.now

        begin
          perform
Severity: Minor
Found in lib/instance_agent/agent/base.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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def execute
          #If the file doesn't exist the command is ignored
          if File.symlink?(@file_path)
            FileUtils.rm(@file_path)
          elsif File.exist?(@file_path)
Severity: Minor
Found in lib/instance_agent/plugins/codedeploy/install_instruction.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 with_error_handling has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def with_error_handling
    yield
  rescue SocketError => e
    log(:info, "#{description}: failed to run as the connection failed! #{e.class} - #{e.message} - #{e.backtrace.join("\n")}")
    sleep InstanceAgent::Config.config[:wait_after_connection_problem]
Severity: Minor
Found in lib/winagent.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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def initialize(configuration_file_location = CONF_DEFAULT_LOCATION)
          configuration_file_location ||= CONF_DEFAULT_LOCATION # Default gets set this way even if the input is nil
          if IS_WINDOWS then self.class.configure_windows_certificate end

          if File.file?(configuration_file_location) && File.readable?(configuration_file_location)
Severity: Minor
Found in lib/aws/codedeploy/local/deployer.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 with_error_handling has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def with_error_handling
        yield
      rescue SocketError => e
        ProcessManager::Log.info "#{description}: failed to run as the connection failed! #{e.class} - #{e.message} - #{e.backtrace.join("\n")}"
        sleep ProcessManager::Config.config[:wait_after_connection_problem]
Severity: Minor
Found in lib/instance_agent/runner/child.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 download_from_github has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def download_from_github(deployment_spec, account, repo, commit, anonymous, token)
Severity: Minor
Found in lib/instance_agent/plugins/codedeploy/command_executor.rb - About 45 mins to fix

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

            def is_command_noop?(command_name, deployment_spec)
              deployment_spec = InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(deployment_spec)
    
              # DownloadBundle and Install are never noops.
              return false if command_name == "Install" || command_name == "DownloadBundle"
    Severity: Minor
    Found in lib/instance_agent/plugins/codedeploy/command_executor.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 download_from_s3 has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            def download_from_s3(deployment_spec, bucket, key, version, etag)
    Severity: Minor
    Found in lib/instance_agent/plugins/codedeploy/command_executor.rb - About 35 mins to fix

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

                def get_ace
                  result = "";
                  if @default
                    result = "default:"
                  end

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

                def matches_simple_glob(name, pattern)
                  if name.include?(File::SEPARATOR)
                    return false
                  end
                  options = expand(pattern.chars.entries)

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

              def github_revision(location, uri, bundle_type)
                if uri.host == 'github.com' && match = uri.path.match(/\/([^\/]*)\/(.*)$/i)
                  owner, repository_name = match.captures
                  commit = 'HEAD'
                elsif match = uri.path.match(/\/repos\/([^\/]*)\/([^\/]*)\/.*\/(.*)$/i)
      Severity: Minor
      Found in lib/aws/codedeploy/local/deployer.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

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

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

        def service_main
          read_config
          log(:info, 'started')
          shutdown_flag = false
          while running? && !shutdown_flag
      Severity: Minor
      Found in lib/winagent.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 create_script_log_file_if_needed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def create_script_log_file_if_needed
                script_log_file_location = File.join(@current_deployment_root_dir, ScriptLog::SCRIPT_LOG_FILE_RELATIVE_LOCATION)
                if(!File.exists?(script_log_file_location))
                  unless File.directory?(File.dirname(script_log_file_location))
                    FileUtils.mkdir_p(File.dirname(script_log_file_location))
      Severity: Minor
      Found in lib/instance_agent/plugins/codedeploy/hook_executor.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 generate_directory_copy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def generate_directory_copy(i, absolute_source_path, destination, file_exists_behavior)
                unless File.directory?(destination)
                  i.mkdir(destination)
                end
      
      
      Severity: Minor
      Found in lib/instance_agent/plugins/codedeploy/installer.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 set_permissions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def set_permissions(object, permission)
                object = sanitize_dir_path(object)
                log(:debug, "Setting permissions on #{object}")
                raise "The deployment failed because the permissions setting for (#{object}) is specified more than once in the application specification file. Update the files section of the AppSpec file, and then try again." if @permission_targets.include?(object)
                @permission_targets.add(object)
      Severity: Minor
      Found in lib/instance_agent/plugins/codedeploy/install_instruction.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 revision has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def revision(location, bundle_type)
                uri = URI.parse(location)
                if (uri.scheme == 's3')
                  s3_revision(location, uri, bundle_type)
                elsif (uri.scheme == 'https' && uri.host.end_with?('github.com'))
      Severity: Minor
      Found in lib/aws/codedeploy/local/deployer.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 delete_folder has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.delete_folder (dir)
            if dir != nil && dir != "/"
              output = `rd /s /q "#{dir}" 2>&1`
              exit_status = $?.exitstatus
              log(:debug, "Command status: #{$?}")
      Severity: Minor
      Found in lib/instance_agent/platform/windows_util.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