aws/aws-codedeploy-agent

View on GitHub

Showing 87 of 87 total issues

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

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

          rescue ScriptError => e
            log(:debug, 'Calling PutHostCommandComplete: "Code Error" ')
            @deploy_control_client.put_host_command_complete(
            :command_status => "Failed",
            :diagnostics => {:format => "JSON", :payload => gather_diagnostics_from_script_error(e)},
Severity: Minor
Found in lib/instance_agent/plugins/codedeploy/command_poller.rb and 1 other location - About 45 mins to fix
lib/instance_agent/plugins/codedeploy/command_poller.rb on lines 153..161

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

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

          rescue Exception => e
            log(:debug, 'Calling PutHostCommandComplete: "Code Error" ')
            @deploy_control_client.put_host_command_complete(
            :command_status => "Failed",
            :diagnostics => {:format => "JSON", :payload => gather_diagnostics_from_error(e)},
Severity: Minor
Found in lib/instance_agent/plugins/codedeploy/command_poller.rb and 1 other location - About 45 mins to fix
lib/instance_agent/plugins/codedeploy/command_poller.rb on lines 145..161

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

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

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

    def self.execute_zip_command(cmd)
      log(:debug, "Executing #{cmd}")

      output = `#{cmd} 2>&1`
      exit_status = $?.exitstatus
Severity: Major
Found in lib/instance_agent/platform/windows_util.rb and 2 other locations - About 45 mins to fix
lib/instance_agent/platform/linux_util.rb on lines 107..119
lib/instance_agent/platform/linux_util.rb on lines 124..136

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

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

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

    def self.execute_zip_command(cmd)
      log(:debug, "Executing #{cmd}")

      output = `#{cmd} 2>&1`
      exit_status = $?.exitstatus
Severity: Major
Found in lib/instance_agent/platform/linux_util.rb and 2 other locations - About 45 mins to fix
lib/instance_agent/platform/linux_util.rb on lines 107..119
lib/instance_agent/platform/windows_util.rb on lines 92..104

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

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

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

        def self.execute_tar_command(cmd)
          log(:debug, "Executing #{cmd}")
    
          output = `#{cmd} 2>&1`
          exit_status = $?.exitstatus
    Severity: Major
    Found in lib/instance_agent/platform/linux_util.rb and 2 other locations - About 45 mins to fix
    lib/instance_agent/platform/linux_util.rb on lines 124..136
    lib/instance_agent/platform/windows_util.rb on lines 92..104

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

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

      Severity
      Category
      Status
      Source
      Language