cloudfoundry/warden

View on GitHub

Showing 73 of 73 total issues

Class Base has 78 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Base
      include EventEmitter
      include Spawn

      class << self
Severity: Major
Found in warden/lib/warden/container/base.rb - About 1 day to fix

    File base.rb has 631 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "warden/container/spawn"
    require "warden/errors"
    require "warden/event_emitter"
    require "warden/util"
    
    
    Severity: Major
    Found in warden/lib/warden/container/base.rb - About 1 day to fix

      File pb.rb has 541 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require "beefcake"
      
      module Warden
        module Protocol
      
      
      Severity: Major
      Found in warden-protocol/lib/warden/protocol/pb.rb - About 1 day to fix

        File server.rb has 399 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require "warden/config"
        require "warden/container"
        require "warden/errors"
        require "warden/event_emitter"
        require "warden/network"
        Severity: Minor
        Found in warden/lib/warden/server.rb - About 5 hrs to fix

          File commands_manager.rb has 374 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require "warden/protocol"
          require "forwardable"
          
          module Warden::Repl
            module CommandsManager
          Severity: Minor
          Found in warden/lib/warden/repl/commands_manager.rb - About 5 hrs to fix

            Method populate_request has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
            Open

                def populate_request(request, arguments, field_delim = ".")
                  # Handle to the proto buf object that will be populated with a value.
                  pb_handle = nil
                  # Name of field and its type to be populated into pb_handle.
                  last_parsed = {}
            Severity: Minor
            Found in warden/lib/warden/repl/commands_manager.rb - About 4 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 V1 has 35 methods (exceeds 20 allowed). Consider refactoring.
            Open

                class V1
                  def self.request_from_v1(args)
                    command = args.shift
            
                    m = "convert_#{command}_request".downcase
            Severity: Minor
            Found in warden-client/lib/warden/client/v1.rb - About 4 hrs to fix

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

                      def exec!
                        # The signal handler MUST be installed before spawning a new process
                        SignalHandler.setup!
              
                        if RUBY_PLATFORM =~ /linux/i && @options.delete(:close_others)
              Severity: Minor
              Found in em-posix-spawn/lib/em/posix/spawn/child.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

              Method process_command has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
              Open

                  def process_command(command_args)
                    command_info = { :result => "" }
                    command_info[:result] << "+ #{command_args.join(" ")}\n" if @trace
              
                    command = deserialize(command_args)
              Severity: Minor
              Found in warden/lib/warden/repl/repl_v2.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

              File child.rb has 305 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'eventmachine'
              require 'posix/spawn'
              
              module EventMachine
              
              
              Severity: Minor
              Found in em-posix-spawn/lib/em/posix/spawn/child.rb - About 3 hrs to fix

                Method start has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                    def start
                      restore_history
                      @client.connect unless @client.connected?
                
                      comp = proc { |s|
                Severity: Minor
                Found in warden/lib/warden/repl/repl_v2.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

                Method do_generate_help has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                    def do_generate_help(cmd_type, opts = {})
                      help = {}
                      help[:description] = command_descriptions[to_type(cmd_type)]
                
                      help_generator = lambda do |field, prefix|
                Severity: Minor
                Found in warden/lib/warden/repl/commands_manager.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

                Method acquire has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                      def acquire(opts = {})
                        if !@resources.has_key?("container_id")
                          @resources["container_id"] = self.class.generate_container_id
                        end
                
                
                Severity: Minor
                Found in warden/lib/warden/container/base.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

                Method populate_request has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def populate_request(request, arguments, field_delim = ".")
                      # Handle to the proto buf object that will be populated with a value.
                      pb_handle = nil
                      # Name of field and its type to be populated into pb_handle.
                      last_parsed = {}
                Severity: Major
                Found in warden/lib/warden/repl/commands_manager.rb - About 3 hrs to fix

                  Method exec! has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          def exec!
                            # The signal handler MUST be installed before spawning a new process
                            SignalHandler.setup!
                  
                            if RUBY_PLATFORM =~ /linux/i && @options.delete(:close_others)
                  Severity: Major
                  Found in em-posix-spawn/lib/em/posix/spawn/child.rb - About 2 hrs to fix

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

                        def do_serialize(obj, field_delim = ".")
                          return obj.to_s if !obj.is_a?(Warden::Protocol::BaseMessage)
                    
                          append_serialized = lambda do |key, source, target_hash, field_delim|
                            if source.is_a?(Hash)
                    Severity: Minor
                    Found in warden/lib/warden/repl/commands_manager.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

                    Method do_limit_disk has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def do_limit_disk(request, response)
                              # return directly if the disk quota is diabled
                              return nil unless self.class.disk_quota_enabled
                    
                              # Use current limits as defaults
                    Severity: Minor
                    Found in warden/lib/warden/container/features/quota.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

                    Method run has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def self.run(args = [])
                          options = {}
                    
                          opt_parser = OptionParser.new do |op|
                            op.banner = <<-EOT
                    Severity: Minor
                    Found in warden/lib/warden/repl/repl_v2_runner.rb - About 2 hrs to fix

                      Method write_bind_mount_commands has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def write_bind_mount_commands(request)
                              File.open(File.join(container_path, "lib", "hook-child-before-pivot.sh"), "a") do |file|
                                file.puts
                                file.puts
                      
                      
                      Severity: Minor
                      Found in warden/lib/warden/container/linux.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 do_limit_disk has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              def do_limit_disk(request, response)
                                # return directly if the disk quota is diabled
                                return nil unless self.class.disk_quota_enabled
                      
                                # Use current limits as defaults
                      Severity: Minor
                      Found in warden/lib/warden/container/features/quota.rb - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language