symplely/coroutine

View on GitHub

Showing 209 of 236 total issues

Method net_listen has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    $handle,
    int $handlerTask,
    int $backlog = 0,
    ?string $ssl_path = None,
    ?string $ssl_file = None,
Severity: Major
Found in Coroutine/Socket.php - About 50 mins to fix

    Method spawn_task has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

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

      Method spawn_await has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

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

        Method add_future has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

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

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

                        if ($result < 0) {
                          // @codeCoverageIgnoreStart
                          \uv_fs_close($coroutine->getUV(), $fd, function () use ($task, $coroutine) {
                            $coroutine->fsRemove();
                            $task->setException(new \Exception("write error"));
          Severity: Minor
          Found in Coroutine/FileSystem.php and 1 other location - About 50 mins to fix
          Coroutine/FileSystem.php on lines 1123..1135

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

          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

                        if ($status < 0) {
                          // @codeCoverageIgnoreStart
                          \uv_fs_close($coroutine->getUV(), $fd, function () use ($task, $coroutine) {
                            $coroutine->fsRemove();
                            $task->setException(new \Exception("read error"));
          Severity: Minor
          Found in Coroutine/FileSystem.php and 1 other location - About 50 mins to fix
          Coroutine/FileSystem.php on lines 1184..1196

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

          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 mailWriter has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              $to,
              $subject = null,
              array $headers = [],
              $levels = self::ALL,
              $interval = 1,
          Severity: Minor
          Found in Coroutine/Logger/Logger.php - About 45 mins to fix

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

              protected function elements(iterable ...$items): array
              {
                $elements = [];
                if (isset($items[0]) && \is_array($items[0])) {
                  foreach ($items as $key => $value) {
            Severity: Minor
            Found in Coroutine/Misc/Datatype/Dict.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

            Method create_default_context has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                string $purpose,
                ?string $name = None,
                $context = [],
                ?string $capath = None,
                ?string $cafile = None,
            Severity: Minor
            Found in Coroutine/Misc/Network/SSLContext.php - About 45 mins to fix

              Method net_request has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  $object,
                  string $method = 'GET',
                  string $path = '/',
                  ?string $type = 'text/html',
                  $data = null,
              Severity: Minor
              Found in Coroutine/Socket.php - About 45 mins to fix

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

                    public function getReturn()
                    {
                        if ($this->isTerminated()) {
                            return !empty($this->result) ? $this->result : $this->finishResult;
                        } elseif (!$this->isStarted() || $this->isActive() || $this->isErred()) {
                Severity: Minor
                Found in Coroutine/Fiber/Fiber.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

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

                  public static function listenerTask(callable $handler)
                  {
                    return Kernel::away(function () use ($handler) {
                      $coroutine = \coroutine();
                      $tid = yield \stateless_task();
                Severity: Minor
                Found in Coroutine/Networks.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

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

                  public function do_handshake()
                  {
                    \stream_set_blocking($this->stream, true);
                    $secure = self::accepting();
                    \stream_set_blocking($this->stream, false);
                Severity: Minor
                Found in Coroutine/Misc/Network/Sockets.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

                Method mailWriter has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    $to,
                    $subject = null,
                    array $headers = [],
                    $levels = self::ALL,
                    $interval = 1,
                Severity: Minor
                Found in Coroutine/Logger/AsyncLoggerInterface.php - About 45 mins to fix

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

                    public static function read($handle, $size = -1)
                    {
                      if (self::isUv() && $handle instanceof \UV) {
                        if (\uv_is_closing($handle))
                          return false;
                  Severity: Minor
                  Found in Coroutine/Networks.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

                  Method create_ssl_context has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      string $purpose,
                      ?string $name = None,
                      $context = [],
                      ?string $capath = None,
                      ?string $cafile = None,
                  Severity: Minor
                  Found in Coroutine/Socket.php - About 45 mins to fix

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

                      public static function create_default_context(
                        string $purpose,
                        ?string $name = None,
                        $context = [],
                        ?string $capath = None,
                    Severity: Minor
                    Found in Coroutine/Misc/Network/SSLContext.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

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

                      function coroutine_run($routine = null, ...$args): void
                      {
                        $isAsync = false;
                        if (\is_string($routine) && Co::isFunction($routine)) {
                          $isAsync = true;
                    Severity: Minor
                    Found in Coroutine/Core.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

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

                      public static function write($handle, $data = '')
                      {
                        if (self::isUv() && $handle instanceof \UV) {
                          if (\uv_is_closing($handle))
                            return false;
                    Severity: Minor
                    Found in Coroutine/Networks.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.
                    Open

                                  if ($enabled === false)
                                    throw new \RuntimeException(\sprintf('Failed to enable socket encryption: %s', \error_get_last()['message'] ?? ''));
                    Severity: Major
                    Found in Coroutine/Networks.php - About 45 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language