socketry/async-container

View on GitHub

Showing 9 of 9 total issues

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

            def run
                # I thought this was the default... but it doesn't always raise an exception unless you do this explicitly.
                interrupt_action = Signal.trap(:INT) do
                    raise Interrupt
                end
Severity: Minor
Found in lib/async/container/controller.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 spawn has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

            def spawn(name: nil, restart: false, key: nil, &block)
                name ||= UNNAMED
                
                if mark?(key)
                    Async.logger.debug(self) {"Reusing existing child for #{key}: #{name}"}
Severity: Minor
Found in lib/async/container/generic.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 spawn has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            def spawn(name: nil, restart: false, key: nil, &block)
                name ||= UNNAMED
                
                if mark?(key)
                    Async.logger.debug(self) {"Reusing existing child for #{key}: #{name}"}
Severity: Minor
Found in lib/async/container/generic.rb - About 1 hr to fix

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

                def run
                    # I thought this was the default... but it doesn't always raise an exception unless you do this explicitly.
                    interrupt_action = Signal.trap(:INT) do
                        raise Interrupt
                    end
    Severity: Minor
    Found in lib/async/container/controller.rb - About 1 hr to fix

      Method restart has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  def restart
                      if @container
                          @notify&.restarting!
                          
                          Async.logger.debug(self) {"Restarting container..."}
      Severity: Minor
      Found in lib/async/container/controller.rb - About 1 hr to fix

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

                    def stop(timeout = 1)
                        # Use a default timeout if not specified:
                        timeout = 1 if timeout == true
                        
                        if timeout
        Severity: Minor
        Found in lib/async/container/group.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 restart has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                    def restart
                        if @container
                            @notify&.restarting!
                            
                            Async.logger.debug(self) {"Restarting container..."}
        Severity: Minor
        Found in lib/async/container/controller.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 wait_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                    def wait_for(channel)
                        io = channel.in
                        
                        @running[io] = Fiber.current
                        
        Severity: Minor
        Found in lib/async/container/group.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 wait has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                    def wait
                        if @pid && @status.nil?
                            _, @status = ::Process.wait2(@pid, ::Process::WNOHANG)
                            
                            if @status.nil?
        Severity: Minor
        Found in lib/async/container/process.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