symplely/coroutine

View on GitHub

Showing 209 of 236 total issues

File Loggers.php has 261 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

use Async\Log;
Severity: Minor
Found in Coroutine/Loggers.php - About 2 hrs to fix

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

      public static function meta($fd = null, ?string $info = null)
      {
        if (!\is_resource($fd) && ($info == 'status' || $info == 'size'))
          return $info == 'status' ? 400 : 0;
        elseif (!\is_resource($fd))
    Severity: Minor
    Found in Coroutine/FileSystem.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

    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

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

      public static function rmdir(string $path)
      {
        if (self::isUv()) {
          return new Kernel(
            function (TaskInterface $task, CoroutineInterface $coroutine) use ($path) {
    Severity: Major
    Found in Coroutine/FileSystem.php and 1 other location - About 2 hrs to fix
    Coroutine/FileSystem.php on lines 215..235

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

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

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

    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 get_local()
      {
        if ($this->secured) {
          if (\is_resource($this->stream))
            return \stream_socket_get_name($this->stream, false);
    Severity: Major
    Found in Coroutine/Misc/Network/Sockets.php and 1 other location - About 2 hrs to fix
    Coroutine/Misc/Network/Sockets.php on lines 501..517

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

    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 get_peer()
      {
        if ($this->secured) {
          if (\is_resource($this->stream))
            return \stream_socket_get_name($this->stream, true);
    Severity: Major
    Found in Coroutine/Misc/Network/Sockets.php and 1 other location - About 2 hrs to fix
    Coroutine/Misc/Network/Sockets.php on lines 519..535

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

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

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

      Function fromKeys has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        public static function fromKeys(iterable $iterable, $value = None): DictIterator
        {
          $elements = [];
          if ($iterable instanceof DictIterator) {
            foreach ($iterable->list() as $key)
      Severity: Minor
      Found in Coroutine/Misc/Datatype/Dict.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 listen has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public static function listen($server, int $listenerTask, int $backlog = 0)
            {
              if (self::isUv() && ($server instanceof \UVStream || $server instanceof \UVUdp)) {
                return yield new Kernel(
                  function (TaskInterface $task, CoroutineInterface $coroutine) use ($server, $listenerTask, $backlog) {
          Severity: Minor
          Found in Coroutine/Networks.php - About 1 hr to fix

            Function server has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              public static function server(
                $uri,
                ?OptionsInterface $context = null,
                ?string $capath = None,
                ?string $cafile = None,
            Severity: Minor
            Found in Coroutine/Networks.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 handleClient has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            function handleClient($socket)
            {
                global $i;
                $data = yield net_read($socket);
            
            
            Severity: Minor
            Found in examples/WebServer/server.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 elements has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              protected function elements(...$items): array
              {
                $elements = [];
                if (\is_iterable($items)) {
                  $items = isset($items[0]) && \is_array($items[0]) ? $items[0] : $items;
            Severity: Minor
            Found in Coroutine/Misc/Datatype/Tuple.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 extend has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              public function extend(iterable $list): void
              {
                $elements = [];
                if ($list instanceof DictIterator) {
                  foreach ($list() as $key => $value)
            Severity: Minor
            Found in Coroutine/Misc/Datatype/Lists.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 input has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              public static function input(int $size = 256, bool $error = false)
              {
                //Check on STDIN stream
                $blocking = \stream_set_blocking(\STDIN, false);
                if ($error && !$blocking) {
            Severity: Minor
            Found in Coroutine/Coroutine.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 shutdown has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              public function shutdown(?int $skipTask = 1)
              {
                if ($skipTask === 1)
                  $skipTask = Co::getUnique('parent');
            
            
            Severity: Minor
            Found in Coroutine/Coroutine.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 server has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              public static function server(
                $uri,
                ?OptionsInterface $context = null,
                ?string $capath = None,
                ?string $cafile = None,
            Severity: Minor
            Found in Coroutine/Networks.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
                Severity
                Category
                Status
                Source
                Language