symplely/coroutine

View on GitHub

Showing 180 of 236 total issues

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

Function execute has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
Open

  public function execute($isReturn = false)
  {
    while (!$this->taskQueue->isEmpty()) {
      /** @var TaskInterface|FiberInterface */
      $task = $this->taskQueue->dequeue();
Severity: Minor
Found in Coroutine/Coroutine.php - About 1 day 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 Networks.php has 529 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Async;
Severity: Major
Found in Coroutine/Networks.php - About 1 day to fix

    Function client has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
    Open

      public static function client($uri = null, OptionsInterface $context = null)
      {
        [$parts, $uri, $ip,] = yield net_getaddrinfo((string)$uri);
        $isSSL = \in_array($parts['scheme'], ['https', 'wss', 'tls', 'ssl']) || $parts['port'] === 443
          || ($context instanceof SSLContext);
    Severity: Minor
    Found in Coroutine/Networks.php - About 7 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 getaddrinfo has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

      function getaddrinfo($host = null, ?string $service = null, array $hints = [])
      {
        $address = $host;
        $uri = (empty($host) || $host === 'localhost') ? 0 : $host;
        $ip = null;
    Severity: Minor
    Found in Coroutine/Internal.php - About 6 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 join has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

      public function join()
      {
        $coroutine = \coroutine();
        try {
          // We wait for no-one. Tasks get cancelled on return.
    Severity: Minor
    Found in Coroutine/Misc/TaskGroup.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

    File Sockets.php has 384 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    declare(strict_types=1);
    
    namespace Async\Network;
    Severity: Minor
    Found in Coroutine/Misc/Network/Sockets.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

      File Logger.php has 355 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      declare(strict_types=1);
      
      namespace Async;
      Severity: Minor
      Found in Coroutine/Logger/Logger.php - About 4 hrs to fix

        Sockets has 33 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Sockets extends Context implements SocketsInterface
        {
          /**
           * Hints for **AddressInfo**, a `addrinfo` structure used by the `socket_addrinfo_lookup()` function to hold host address information.
           *
        Severity: Minor
        Found in Coroutine/Misc/Network/Sockets.php - About 4 hrs to fix

          Function create has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

            public static function create(\Generator $gen)
            {
              $stack = new \SplStack;
              $exception = null;
          
          
          Severity: Minor
          Found in Coroutine/Coroutine.php - 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

          File Task.php has 329 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          declare(strict_types=1);
          
          namespace Async;
          Severity: Minor
          Found in Coroutine/Task.php - About 3 hrs to fix

            Fiber has 29 functions (exceeds 20 allowed). Consider refactoring.
            Open

            final class Fiber implements FiberInterface
            {
                /**
                 * @var TaskInterface|FiberInterface|null
                 */
            Severity: Minor
            Found in Coroutine/Fiber/Fiber.php - About 3 hrs to fix

              Logger has 29 functions (exceeds 20 allowed). Consider refactoring.
              Open

              final class Logger extends AsyncLogger implements AsyncLoggerInterface
              {
                private static $levels = [
                  self::DEBUG     => LogLevel::DEBUG,
                  self::INFO      => LogLevel::INFO,
              Severity: Minor
              Found in Coroutine/Logger/Logger.php - About 3 hrs to fix

                Function adding has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                Open

                  public function adding(?\closure $future = null, ?string $include = null, ...$args): FutureInterface
                  {
                    $defined = Globals::get();
                
                    if (!\is_callable($future) && !$future instanceof FutureInterface) {
                Severity: Minor
                Found in Coroutine/Parallel.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

                Lists has 28 functions (exceeds 20 allowed). Consider refactoring.
                Open

                final class Lists implements ListsIterator
                {
                  /**
                   * @var array
                   */
                Severity: Minor
                Found in Coroutine/Misc/Datatype/Lists.php - About 3 hrs to fix

                  Dict has 27 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  final class Dict implements DictIterator
                  {
                    /**
                     * @var array
                     */
                  Severity: Minor
                  Found in Coroutine/Misc/Datatype/Dict.php - About 3 hrs to fix

                    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

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

                      public function __destruct()
                      {
                        if ($this->destructed) {
                          return;
                        }
                    Severity: Minor
                    Found in Coroutine/Defer.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

                    File SocketMessage.php has 293 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    <?php
                    
                    declare(strict_types=1);
                    
                    namespace Async;
                    Severity: Minor
                    Found in Coroutine/SocketMessage.php - About 3 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language