cloudfoundry/dea_ng

View on GitHub

Showing 79 of 89 total issues

File instance.rb has 731 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'membrane'
require 'steno'
require 'steno/core_ext'
require 'yaml'

Severity: Major
Found in lib/dea/starting/instance.rb - About 1 day to fix

    Class Instance has 65 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Instance < Task
        include EventEmitter
    
        STAT_COLLECTION_INTERVAL_SECS = 10
    
    
    Severity: Major
    Found in lib/dea/starting/instance.rb - About 1 day to fix

      Class StagingTask has 57 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class StagingTask < Task
          class StagingError < StandardError
            def initialize(msg)
              super("Error staging: #{msg}")
            end
      Severity: Major
      Found in lib/dea/staging/staging_task.rb - About 1 day to fix

        File staging_task.rb has 503 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'tempfile'
        require 'tmpdir'
        require 'yaml'
        require 'shellwords'
        
        
        Severity: Major
        Found in lib/dea/staging/staging_task.rb - About 1 day to fix

          Class Bootstrap has 47 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class Bootstrap
              DEFAULT_HEARTBEAT_INTERVAL = 10 # In secs
              DEFAULT_METRICS_INTERVAL = 30
              DROPLET_REAPER_INTERVAL_SECS = 60
              CONTAINER_REAPER_INTERVAL_SECS = 600
          Severity: Minor
          Found in lib/dea/bootstrap.rb - About 6 hrs to fix

            File bootstrap.rb has 428 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require "set"
            
            require "steno"
            require "steno/config"
            require "steno/core_ext"
            Severity: Minor
            Found in lib/dea/bootstrap.rb - About 6 hrs to fix

              Method schema has 98 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def self.schema
                    ::Membrane::SchemaParser.parse do
                      {
                        "base_dir" => String,
              
              
              Severity: Major
              Found in lib/dea/config.rb - About 3 hrs to fix

                Method send has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                Open

                    def send(response, iteration, &blk)
                      if iteration > MAX_RETRIES
                        blk.call if blk
                      else
                        destination = URI.join(@destination, "/internal/dea/staging/#{response[:app_id]}/completed")
                Severity: Minor
                Found in lib/dea/utils/cloud_controller_client.rb - About 3 hrs 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

                Class Container has 27 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class Container
                  class WardenError < StandardError
                    attr_reader :result
                
                    def initialize(message, response=nil)
                Severity: Minor
                Found in lib/container/container.rb - About 3 hrs to fix

                  Method StreamHandler.ServeHTTP has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (handler *StreamHandler) ServeHTTP(writer http.ResponseWriter, r *http.Request) {
                      var err error
                  
                      watcher, err := fsnotify.NewWatcher()
                      if err != nil {
                  Severity: Minor
                  Found in go/src/directoryserver/stream_handler.go - About 3 hrs 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 has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def download
                      logger.debug("admin-buildpacks.download", buildpacks: @buildpacks)
                      return unless @buildpacks
                  
                      FileUtils.mkdir_p(@destination_directory)
                  Severity: Minor
                  Found in lib/dea/staging/admin_buildpack_downloader.rb - About 2 hrs 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

                  Class InstanceRegistry has 25 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                    class InstanceRegistry
                      DEFAULT_CRASH_LIFETIME_SECS  = 60 * 60
                      CRASHES_REAPER_INTERVAL_SECS = 10
                      DEFAULT_STOPPING_LIFETIME_SECS = 60
                  
                  
                  Severity: Minor
                  Found in lib/dea/starting/instance_registry.rb - About 2 hrs to fix

                    Class StagingMessage has 24 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class StagingMessage
                      def initialize(message)
                        @message = message
                      end
                    
                    
                    Severity: Minor
                    Found in lib/dea/staging/staging_message.rb - About 2 hrs to fix

                      Class StartMessage has 24 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class StartMessage
                        def initialize(message)
                          @message = message
                        end
                      
                      
                      Severity: Minor
                      Found in lib/dea/starting/start_message.rb - About 2 hrs to fix

                        Class StagingTaskWorkspace has 24 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                          class StagingTaskWorkspace
                            DROPLET_FILE = "droplet.tgz".freeze
                            BUILDPACK_CACHE_FILE = "buildpack_cache.tgz".freeze
                            STAGING_LOG = "staging_task.log".freeze
                            STAGING_INFO = "staging_info.yml".freeze
                        Severity: Minor
                        Found in lib/dea/staging/staging_task_workspace.rb - About 2 hrs to fix

                          Method load has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def load
                                return unless File.exist?(path)
                          
                                start = Time.now
                          
                          
                          Severity: Minor
                          Found in lib/dea/snapshot.rb - About 2 hrs 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

                          Class Config has 22 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                            class Config
                              DEFAULT_STAGING_DISK_INODE_LIMIT = 200_000
                              DEFAULT_INSTANCE_DISK_INODE_LIMIT = 200_000
                              DEFAULT_INSTANCE_NPROC_LIMIT = 512
                              DEFAULT_ROUTER_REGISTER_INTERVAL_IN_SECONDS = 20
                          Severity: Minor
                          Found in lib/dea/config.rb - About 2 hrs to fix

                            Method StreamHandler.ServeHTTP has 79 lines of code (exceeds 50 allowed). Consider refactoring.
                            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 2 hrs to fix

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

                                def upload!(&upload_callback)
                                  logger.info("em-upload.begin", destination: URICleaner.clean(@destination))
                              
                                  SyncUpload.new(@source, @destination, @logger).upload! do |http, error|
                                    if error
                              Severity: Minor
                              Found in lib/dea/utils/upload.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 create_instance has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  def create_instance(attributes)
                                    instance = Instance.new(bootstrap, attributes)
                              
                                    begin
                                      instance.validate
                              Severity: Minor
                              Found in lib/dea/starting/instance_manager.rb - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language