symplely/coroutine

View on GitHub

Showing 209 of 236 total issues

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

    Set has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

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

      Function close has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

        public function close()
        {
          if ($this->uv instanceof \UVLoop) {
            foreach ($this->timers as $timer) {
              if ($timer instanceof \UVTimer && \uv_is_active($timer))
      Severity: Minor
      Found in Coroutine/Coroutine.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

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

        public static function chmod(string $filename, int $mode)
        {
          if (self::isUv()) {
            return new Kernel(
              function (TaskInterface $task, CoroutineInterface $coroutine) use ($filename, $mode) {
      Severity: Major
      Found in Coroutine/FileSystem.php and 2 other locations - About 2 hrs to fix
      Coroutine/FileSystem.php on lines 131..152
      Coroutine/FileSystem.php on lines 246..267

      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 139.

      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 3 locations. Consider refactoring.
      Open

        public static function rename(string $from, string $to)
        {
          if (self::isUv()) {
            return new Kernel(
              function (TaskInterface $task, CoroutineInterface $coroutine) use ($from, $to) {
      Severity: Major
      Found in Coroutine/FileSystem.php and 2 other locations - About 2 hrs to fix
      Coroutine/FileSystem.php on lines 246..267
      Coroutine/FileSystem.php on lines 397..418

      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 139.

      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 3 locations. Consider refactoring.
      Open

        public static function link(string $from, string $to)
        {
          if (self::isUv()) {
            return new Kernel(
              function (TaskInterface $task, CoroutineInterface $coroutine) use ($from, $to) {
      Severity: Major
      Found in Coroutine/FileSystem.php and 2 other locations - About 2 hrs to fix
      Coroutine/FileSystem.php on lines 131..152
      Coroutine/FileSystem.php on lines 397..418

      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 139.

      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 function addReader($stream, $task, bool $addEvent = true): CoroutineInterface
        {
          $already = true;
          if (isset($this->waitingForRead[(int) $stream])) {
            $already = false;
      Severity: Major
      Found in Coroutine/Coroutine.php and 1 other location - About 2 hrs to fix
      Coroutine/Coroutine.php on lines 1066..1080

      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 137.

      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 function addWriter($stream, $task, bool $addEvent = true): CoroutineInterface
        {
          $already = true;
          if (isset($this->waitingForWrite[(int) $stream])) {
            $already = false;
      Severity: Major
      Found in Coroutine/Coroutine.php and 1 other location - About 2 hrs to fix
      Coroutine/Coroutine.php on lines 1050..1064

      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 137.

      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

      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

        Co has 24 functions (exceeds 20 allowed). Consider refactoring.
        Open

        final class Co
        {
          /**
           * @var array[]
           */
        Severity: Minor
        Found in Coroutine/Co.php - About 2 hrs to fix

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

            public static function symlink(string $from = null, string $to = null, int $flag = 0)
            {
              if (self::isUv()) {
                return new Kernel(
                  function (TaskInterface $task, CoroutineInterface $coroutine) use ($from, $to, $flag) {
          Severity: Major
          Found in Coroutine/FileSystem.php and 1 other location - About 2 hrs to fix
          Coroutine/FileSystem.php on lines 430..452

          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 134.

          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 chown(string $path, int $uid, int $gid)
            {
              if (self::isUv()) {
                return new Kernel(
                  function (TaskInterface $task, CoroutineInterface $coroutine) use ($path, $uid, $gid) {
          Severity: Major
          Found in Coroutine/FileSystem.php and 1 other location - About 2 hrs to fix
          Coroutine/FileSystem.php on lines 277..299

          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 134.

          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 TaskGroup.php has 275 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

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

            Function getDependencies has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function getDependencies($parameters, $values = null)
                {
                    $dependencies = [];
                    if (\is_array($parameters)) {
                        foreach ($parameters as $parameter) {
            Severity: Minor
            Found in Coroutine/Di/Injection.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 client has 64 lines of code (exceeds 25 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: Major
            Found in Coroutine/Networks.php - About 2 hrs to fix

              SSLContext has 23 functions (exceeds 20 allowed). Consider refactoring.
              Open

              final class SSLContext extends AbstractOptions
              {
                /**
                 *  Setup encryption on the stream. Valid methods are:
                 *
              Severity: Minor
              Found in Coroutine/Misc/Network/SSLContext.php - About 2 hrs to fix

                Function parse has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                  public function parse($headers)
                  {
                    $this->headers = [];
                    $this->parameters = [];
                    $this->path = '';
                Severity: Minor
                Found in Coroutine/SocketMessage.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 join has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  public function join()
                  {
                    $coroutine = \coroutine();
                    try {
                      // We wait for no-one. Tasks get cancelled on return.
                Severity: Major
                Found in Coroutine/Misc/TaskGroup.php - About 2 hrs to fix

                  Method getaddrinfo has 57 lines of code (exceeds 25 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: Major
                  Found in Coroutine/Internal.php - About 2 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language