cloudfoundry/warden

View on GitHub
warden/lib/warden/container/base.rb

Summary

Maintainability
F
3 days
Test Coverage

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

      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 acquire has 41 lines of code (exceeds 25 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 1 hr to fix

        Method spawn_job has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def spawn_job(run_options, *args)
                job_id = self.class.generate_job_id
        
                job_root = job_path(job_id)
                FileUtils.mkdir_p(job_root)
        Severity: Minor
        Found in warden/lib/warden/container/base.rb - About 1 hr to fix

          Method spawn_job has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

                def spawn_job(run_options, *args)
                  job_id = self.class.generate_job_id
          
                  job_root = job_path(job_id)
                  FileUtils.mkdir_p(job_root)
          Severity: Minor
          Found in warden/lib/warden/container/base.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 restore has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def restore
                  acquire
          
                  if @resources.has_key?("ports")
                    self.class.port_pool.delete(*@resources["ports"])
          Severity: Minor
          Found in warden/lib/warden/container/base.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 before_destroy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def before_destroy
                  check_state_in(State::Born, State::Active, State::Stopped, State::Destroyed)
          
                  return if self.state == State::Destroyed
                  begin
          Severity: Minor
          Found in warden/lib/warden/container/base.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

          There are no issues that match your filters.

          Category
          Status