cloudfoundry/dea_ng

View on GitHub

Showing 89 of 89 total issues

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

    def promise_stop(kill_flag = false)
      Promise.new do |p|
        begin
          if container.handle
            request = ::Warden::Protocol::StopRequest.new(handle: container.handle, kill: kill_flag)
Severity: Minor
Found in lib/dea/task.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 emit_metrics has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def emit_metrics(now)
      return unless @container.handle

      info = @container.info
    rescue => e
Severity: Minor
Found in lib/dea/stat_collector.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 shutdown! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def shutdown!(goodbye_message)
    return if shutting_down?
    @shutting_down = true

    remove_droplets
Severity: Minor
Found in lib/dea/lifecycle/shutdown_handler.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 handle_dea_update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def handle_dea_update(message)
      app_id = message.data["droplet"].to_s
      uris = message.data["uris"]
      app_version = message.data["version"]

Severity: Minor
Found in lib/dea/bootstrap.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 promise_start has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def promise_start
      Promise.new do |p|
        env = Env.new(StartMessage.new(@raw_attributes), self)

        if staged_info
Severity: Minor
Found in lib/dea/starting/instance.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 initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def initialize(message_bus, locator_responders, instance_registry, staging_registry, droplet_registry, directory_server, logger)
Severity: Major
Found in lib/dea/lifecycle/shutdown_handler.rb - About 50 mins to fix

    Method initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def initialize(bootstrap, message_bus, locator_responders, instance_registry, staging_task_registry, logger, config)
    Severity: Major
    Found in lib/dea/lifecycle/evacuation_handler.rb - About 50 mins to fix

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

          helpers do
            def json_error!(msg, status)
              error!({ "error" => msg }, status)
            end
      
      
      Severity: Minor
      Found in lib/dea/directory_server/instance_paths.rb and 1 other location - About 50 mins to fix
      lib/dea/directory_server/staging_tasks.rb on lines 20..36

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

      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

          helpers do
            def json_error!(msg, status)
              error!({"error" => msg}, status)
            end
      
      
      Severity: Minor
      Found in lib/dea/directory_server/staging_tasks.rb and 1 other location - About 50 mins to fix
      lib/dea/directory_server/instance_paths.rb on lines 20..36

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

      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 StreamHandler.ServeHTTP has 8 return statements (exceeds 4 allowed).
      Open

      func (handler *StreamHandler) ServeHTTP(writer http.ResponseWriter, r *http.Request) {
          var err error
      
          watcher, err := fsnotify.NewWatcher()
          if err != nil {
      Severity: Major
      Found in go/src/directoryserver/stream_handler.go - About 50 mins to fix

        Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def initialize(destination, key_file, cert_file, ca_file, timeout, custom_logger=nil)
        Severity: Minor
        Found in lib/dea/utils/hm9000.rb - About 45 mins to fix

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

              def self.clone(repository, destination)
                git_url, branch = parse(repository)
                target_dir = File.join(destination, File.basename(git_url.path, File.extname(git_url.path)))
          
                git_branch_option = branch.to_s.empty? ? "" : "-b #{branch}"
          Severity: Minor
          Found in buildpacks/lib/git.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 promise_health_check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def promise_health_check
                Promise.new do |p|
                  begin
                    logger.debug('droplet.health-check.get-container-info')
                    container.update_path_and_ip
          Severity: Minor
          Found in lib/dea/starting/instance.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 2 locations. Consider refactoring.
          Open

              resource :stage do
                post do
                  data = env[Grape::Env::API_REQUEST_BODY]
                  logger.debug('http.request.received', route: route.to_s, body: data)
          
          
          Severity: Minor
          Found in lib/dea/http/app_paths.rb and 1 other location - About 45 mins to fix
          lib/dea/http/app_paths.rb on lines 41..50

          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

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

              resource :apps do
                post do
                  data = env[Grape::Env::API_REQUEST_BODY]
                  logger.debug('http.request.received', route: route.to_s, body: data)
          
          
          Severity: Minor
          Found in lib/dea/http/app_paths.rb and 1 other location - About 45 mins to fix
          lib/dea/http/app_paths.rb on lines 28..37

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

            def self.clean_uri(u)
              uri = u.is_a?(URI) ? u.dup : URI.parse(u)
              uri.password = nil if uri.password
              uri.user = nil if uri.user
              uri.to_s
          Severity: Minor
          Found in lib/dea/utils/uri_cleaner.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 handle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def handle(request)
                message = StagingMessage.new(request.data)
                message.set_responder do |params, &blk|
                  request.respond(params) { blk.call if blk }
                end
          Severity: Minor
          Found in lib/dea/responders/nats_staging.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 start has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def start(&callback)
                p = Promise.new do
                  logger.info('droplet.starting')
          
                  promise_state(State::BORN, State::STARTING).resolve
          Severity: Minor
          Found in lib/dea/starting/instance.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 link has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def link(&callback)
                Promise.resolve(promise_link) do |error, link_response|
                  if error
                    logger.warn('droplet.warden.link.failed', error: error, backtrace: error.backtrace)
          
          
          Severity: Minor
          Found in lib/dea/starting/instance.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 notify_completion has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def notify_completion(staging_message, task)
                task.after_complete_callback do |error|
                  data = {
                    task_id: task.task_id,
                    detected_buildpack: task.detected_buildpack,
          Severity: Minor
          Found in lib/dea/responders/staging.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

          Severity
          Category
          Status
          Source
          Language