cloudfoundry/dea_ng

View on GitHub

Showing 89 of 89 total issues

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

      def transition_instances_to_evacuating(first_time)
        @instance_registry.each do |instance|
          if instance.born? || instance.starting? || instance.resuming? || instance.running?
            @logger.error("Found an unexpected #{instance.state} instance while evacuating") unless first_time
            instance.state = Dea::Instance::State::EVACUATING
    Severity: Minor
    Found in lib/dea/lifecycle/evacuation_handler.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_buildpacks has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def download_buildpacks
          return unless config['staging'] && config['staging']['enabled']
    
          buildpacks_url = URI::join(config['cc_url'], '/internal/buildpacks')
          http = EM::HttpRequest.new(buildpacks_url, :connect_timeout => 5).get
    Severity: Minor
    Found in lib/dea/bootstrap.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 emit_container_metric has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def self.emit_container_metric(app_id, instanceIndex, cpuPercentage, memoryBytes, diskBytes)
    Severity: Minor
    Found in lib/dea/loggregator.rb - About 35 mins to fix

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

          def initialize(nats, dea_id, resource_manager, config, url)
      Severity: Minor
      Found in lib/dea/responders/dea_locator.rb - About 35 mins to fix

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

            def initialize(bootstrap, dir_server, staging_message, buildpacks_in_use, custom_logger=nil)
        Severity: Minor
        Found in lib/dea/staging/staging_task.rb - About 35 mins to fix

          Method run_script has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def run_script(name, script, privileged=false, discard_output=false, log_tag=nil)
          Severity: Minor
          Found in lib/container/container.rb - About 35 mins to fix

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

                def initialize(bootstrap, staging_task_registry, dir_server, resource_manager, config)
            Severity: Minor
            Found in lib/dea/responders/staging.rb - About 35 mins to fix

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

                def handle_http_response(http, polling_destination, upload_callback)
                  if http.response_header.status < 300
                    response = JSON.parse(http.response)
              
                    case response.fetch("entity", {}).fetch("status", nil)
              Severity: Minor
              Found in lib/dea/utils/upload.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 check_state_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def check_state_file
                      return unless File.exists?(path)
              
                      state = Yajl::Parser.parse(File.read(path))
                      if state && state["state"] == "RUNNING"
              Severity: Minor
              Found in lib/dea/health_check/state_file_ready.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 DeaClient.LookupPath has 5 return statements (exceeds 4 allowed).
              Open

              func (x *DeaClient) LookupPath(w http.ResponseWriter, r *http.Request) (string, error) {
                  y := fmt.Sprintf("http://%s:%d%s", x.Host, x.Port, r.URL.String())
              
                  log.Infof("Sending HTTP request to DEA: %s", y)
              
              
              Severity: Major
              Found in go/src/directoryserver/deaclient.go - About 35 mins to fix

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

                    def self.validate_arguments!(*args)
                      source, dest, env = args
                      argfail!(args) unless source && dest && env
                      argfail!(args) unless File.directory?(File.expand_path(source))
                      argfail!(args) unless File.directory?(File.expand_path(dest))
                Severity: Minor
                Found in buildpacks/lib/buildpack.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

                Function fileSizeFormat has 5 return statements (exceeds 4 allowed).
                Open

                func fileSizeFormat(size int64) string {
                    if size >= (1 << 40) {
                        return fmt.Sprintf("%.1fT", float64(size)/(1<<40))
                    }
                
                
                Severity: Major
                Found in go/src/directoryserver/directoryserver.go - About 35 mins to fix

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

                      def promise_exec_hook_script(key)
                        Promise.new do |p|
                          if bootstrap.config['hooks'] && bootstrap.config['hooks'][key]
                            script_path = bootstrap.config['hooks'][key]
                            if File.exist?(script_path)
                  Severity: Minor
                  Found in lib/dea/starting/instance.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_container has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def create_container(params)
                      [:bind_mounts, :limit_cpu, :byte, :inode, :limit_memory, :setup_inbound_network, :rootfs].each do |param|
                        raise ArgumentError, "expecting #{param.to_s} parameter to create container" if params[param].nil?
                      end
                  
                  
                  Severity: Minor
                  Found in lib/container/container.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 translate_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def self.translate_attributes(attributes)
                        attributes = attributes.dup
                  
                        transfer_attr_with_existance_check(attributes, 'instance_index', 'index')
                        transfer_attr_with_existance_check(attributes, 'application_version', 'version')
                  Severity: Minor
                  Found in lib/dea/starting/instance.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 run_in_parallel_and_join has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def run_in_parallel_and_join(*promises)
                          failure = nil
                          promises.each(&:run).each{ |p|
                            begin
                              p.resolve
                  Severity: Minor
                  Found in lib/dea/promise.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 resolve has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def resolve(promise)
                          f = Fiber.new do
                            result = nil
                  
                            begin
                  Severity: Minor
                  Found in lib/dea/promise.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 promise_state has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def promise_state(from, to = nil)
                        Promise.new do |p|
                          if !Array(from).include?(state)
                            p.fail(TransitionError.new(state, to))
                          else
                  Severity: Minor
                  Found in lib/dea/starting/instance.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