symplely/coroutine

View on GitHub

Showing 209 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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        public static function lstat(string $path = '', ?string $info = null)
        {
          if (self::isUv()) {
            return new Kernel(
              function (TaskInterface $task, CoroutineInterface $coroutine) use ($path, $info) {
      Severity: Major
      Found in Coroutine/FileSystem.php and 1 other location - About 4 hrs to fix
      Coroutine/FileSystem.php on lines 685..712

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 175.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        public static function stat(string $path = '', ?string $info = null)
        {
          if (self::isUv()) {
            return new Kernel(
              function (TaskInterface $task, CoroutineInterface $coroutine) use ($path, $info) {
      Severity: Major
      Found in Coroutine/FileSystem.php and 1 other location - About 4 hrs to fix
      Coroutine/FileSystem.php on lines 633..660

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 175.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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

            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

              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

                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

                    Severity
                    Category
                    Status
                    Source
                    Language