symplely/coroutine

View on GitHub
Coroutine/Kernel.php

Summary

Maintainability
F
1 wk
Test Coverage

Function gather has a Cognitive Complexity of 158 (exceeds 5 allowed). Consider refactoring.
Open

  public static function gather(...$taskId)
  {
    return new Kernel(
      function (TaskInterface $task, CoroutineInterface $coroutine) use ($taskId) {
        $gatherCount = self::$gatherCount;
Severity: Minor
Found in Coroutine/Kernel.php - About 3 days 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 Kernel.php has 1075 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

<?php

declare(strict_types=1);

namespace Async;
Severity: Major
Found in Coroutine/Kernel.php - About 2 days to fix

    Method gather has 218 lines of code (exceeds 25 allowed). Consider refactoring.
    Wontfix

      public static function gather(...$taskId)
      {
        return new Kernel(
          function (TaskInterface $task, CoroutineInterface $coroutine) use ($taskId) {
            $gatherCount = self::$gatherCount;
    Severity: Major
    Found in Coroutine/Kernel.php - About 1 day to fix

      Kernel has 40 functions (exceeds 20 allowed). Consider refactoring.
      Wontfix

      final class Kernel
      {
        protected $callback;
        protected static $gatherCount = 0;
        protected static $gatherShouldError = true;
      Severity: Minor
      Found in Coroutine/Kernel.php - About 5 hrs to fix

        Function asyncWith has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
        Open

          public static function asyncWith($context = null, $object = null, array $options = [])
          {
            $di = $options;
            if (\is_object($object) && !$object instanceof ContextInterface) {
              $inject = $di = $object;
        Severity: Minor
        Found in Coroutine/Kernel.php - About 5 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

        Function cancelTask has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

          public static function cancelTask($tid = 0, $customState = null, string $errorMessage = 'Invalid task ID!', bool $type = false)
          {
            return new Kernel(
              function (TaskInterface $task, CoroutineInterface $coroutine) use ($tid, $customState, $errorMessage, $type) {
                $cancelTask = $coroutine->getTask($tid);
        Severity: Minor
        Found in Coroutine/Kernel.php - 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 addFuture has 68 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public static function addFuture(
            $command,
            $timeout = 0,
            bool $display = false,
            $channel = null,
        Severity: Major
        Found in Coroutine/Kernel.php - About 2 hrs to fix

          Function with has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

            public static function with($context = null, \Closure $as = null)
            {
              $task = \coroutine()->getTask(yield \current_task());
              // @codeCoverageIgnoreStart
              if (\is_resource($context)) {
          Severity: Minor
          Found in Coroutine/Kernel.php - 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 __timeoutAfter has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            protected static function __timeoutAfter(float $timeout = 0.0, $callable = null, ...$args)
            {
              return yield yield new Kernel(
                function (TaskInterface $task, CoroutineInterface $coroutine) use ($callable, $timeout, $args) {
                  $skip = false;
          Severity: Major
          Found in Coroutine/Kernel.php - About 2 hrs to fix

            Method cancelTask has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              public static function cancelTask($tid = 0, $customState = null, string $errorMessage = 'Invalid task ID!', bool $type = false)
              {
                return new Kernel(
                  function (TaskInterface $task, CoroutineInterface $coroutine) use ($tid, $customState, $errorMessage, $type) {
                    $cancelTask = $coroutine->getTask($tid);
            Severity: Minor
            Found in Coroutine/Kernel.php - About 1 hr to fix

              Method await has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Wontfix

                public static function await(string $label, ...$arguments)
                {
                  switch ($label) {
                    case 'sleep':
                    case 'sleep_for':
              Severity: Minor
              Found in Coroutine/Kernel.php - About 1 hr to fix

                Method asyncWith has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  public static function asyncWith($context = null, $object = null, array $options = [])
                  {
                    $di = $options;
                    if (\is_object($object) && !$object instanceof ContextInterface) {
                      $inject = $di = $object;
                Severity: Minor
                Found in Coroutine/Kernel.php - About 1 hr to fix

                  Function away has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                    public static function away($label, ...$args)
                    {
                      if (\is_string($label) && Co::isFunction($label)) {
                        return Kernel::createTask(Co::getFunction($label)(...$args), true);
                      }
                  Severity: Minor
                  Found in Coroutine/Kernel.php - 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

                  Function throwable has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                    protected static function throwable(\Throwable $error, CoroutineInterface $coroutine)
                    {
                      yield;
                      $task = $coroutine->getTask(yield \current_task());
                      $task->setState(
                  Severity: Minor
                  Found in Coroutine/Kernel.php - 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 addThread has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    public static function addThread(callable $function, ...$args)
                    {
                      return new Kernel(
                        function (TaskInterface $task, CoroutineInterface $coroutine)
                        use ($function, $args) {
                  Severity: Minor
                  Found in Coroutine/Kernel.php - About 1 hr to fix

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

                      protected static function throwable(\Throwable $error, CoroutineInterface $coroutine)
                      {
                        yield;
                        $task = $coroutine->getTask(yield \current_task());
                        $task->setState(
                    Severity: Minor
                    Found in Coroutine/Kernel.php - About 1 hr to fix

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

                        public static function with($context = null, \Closure $as = null)
                        {
                          $task = \coroutine()->getTask(yield \current_task());
                          // @codeCoverageIgnoreStart
                          if (\is_resource($context)) {
                      Severity: Minor
                      Found in Coroutine/Kernel.php - About 1 hr to fix

                        Function await has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                          public static function await(string $label, ...$arguments)
                          {
                            switch ($label) {
                              case 'sleep':
                              case 'sleep_for':
                        Severity: Minor
                        Found in Coroutine/Kernel.php - 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 away has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Wontfix

                          public static function away($label, ...$args)
                          {
                            if (\is_string($label) && Co::isFunction($label)) {
                              return Kernel::createTask(Co::getFunction($label)(...$args), true);
                            }
                        Severity: Minor
                        Found in Coroutine/Kernel.php - About 1 hr to fix

                          Method addFuture has 8 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              $command,
                              $timeout = 0,
                              bool $display = false,
                              $channel = null,
                              $channelTask = null,
                          Severity: Major
                          Found in Coroutine/Kernel.php - About 1 hr to fix

                            Method spawnTask has 8 arguments (exceeds 4 allowed). Consider refactoring.
                            Wontfix

                                $callable,
                                $timeout = 0,
                                bool $display = false,
                                $channel = null,
                                $channelTask = null,
                            Severity: Major
                            Found in Coroutine/Kernel.php - About 1 hr to fix

                              Function joinTask has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                public static function joinTask(int $tid)
                                {
                                  return new Kernel(
                                    function (TaskInterface $task, CoroutineInterface $coroutine) use ($tid) {
                                      $join = $coroutine->getTask($tid);
                              Severity: Minor
                              Found in Coroutine/Kernel.php - 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 gatherController has 7 arguments (exceeds 4 allowed). Consider refactoring.
                              Wontfix

                                  string $isCustomSate = 'n/a',
                                  ?callable $onPreComplete = null,
                                  ?callable $onProcessing = null,
                                  ?callable $onCompleted = null,
                                  ?callable $onError = null,
                              Severity: Major
                              Found in Coroutine/Kernel.php - About 50 mins to fix

                                Function asyncFor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  public static function asyncFor(AsyncIterator $task, \Closure $as)
                                  {
                                    while (true) {
                                      try {
                                        $item = yield $task->current();
                                Severity: Minor
                                Found in Coroutine/Kernel.php - 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

                                Avoid deeply nested control flow statements.
                                Wontfix

                                                  if ($subCount == 0)
                                                    break;
                                Severity: Major
                                Found in Coroutine/Kernel.php - About 45 mins to fix

                                  Function progressTask has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                    public static function progressTask(callable $handler)
                                    {
                                      return Kernel::away(function () use ($handler) {
                                        yield;
                                        while (true) {
                                  Severity: Minor
                                  Found in Coroutine/Kernel.php - 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

                                  Avoid too many return statements within this method.
                                  Open

                                          return yield Kernel::gather(...$arguments);
                                  Severity: Major
                                  Found in Coroutine/Kernel.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                            return yield $misc_function(...$arguments);
                                    Severity: Major
                                    Found in Coroutine/Kernel.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                              return yield Kernel::spawnTask($system, 0, $display);
                                      Severity: Major
                                      Found in Coroutine/Kernel.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                              return yield Co::getFunction($label)(...$arguments);
                                        Severity: Major
                                        Found in Coroutine/Kernel.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                  return @$label(...$arguments);
                                          Severity: Major
                                          Found in Coroutine/Kernel.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                  return yield $function(...$arguments);
                                            Severity: Major
                                            Found in Coroutine/Kernel.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                    return yield $file_function(...$arguments);
                                              Severity: Major
                                              Found in Coroutine/Kernel.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                      return yield awaitable_future(function () use ($system, $display) {
                                                        return Kernel::addFuture($system, 0, $display);
                                                      });
                                                Severity: Major
                                                Found in Coroutine/Kernel.php - About 30 mins to fix

                                                  Function __timeoutAfter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                    protected static function __timeoutAfter(float $timeout = 0.0, $callable = null, ...$args)
                                                    {
                                                      return yield yield new Kernel(
                                                        function (TaskInterface $task, CoroutineInterface $coroutine) use ($callable, $timeout, $args) {
                                                          $skip = false;
                                                  Severity: Minor
                                                  Found in Coroutine/Kernel.php - 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