symplely/coroutine

View on GitHub

Showing 209 of 236 total issues

Function cancelProgress has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  public function cancelProgress(TaskInterface $task)
  {
    $channel = $task->getCustomState();
    if (\is_array($channel) && (\count($channel) == 2)) {
      [$channel, $channelTask] = $channel;
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 removeSignal has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  public function removeSignal($signal, $listener)
  {
    if (!$this->signaler || !$this->signaler->count($signal))
      return;

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 addThread has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public static function addThread(callable $function, ...$args)
  {
    return new Kernel(
      function (TaskInterface $task, CoroutineInterface $coroutine)
      use ($function, $args) {
Severity: Minor
Found in Coroutine/Kernel.php - About 1 hr to fix

    Method run has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      public function run()
      {
        if ($this->beforeFirstYield) {
          $this->beforeFirstYield = false;
          return ($this->coroutine instanceof \Generator)
    Severity: Minor
    Found in Coroutine/Task.php - About 1 hr to fix

      Method response has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public function response(
          ?string $body = null,
          ?int $status = null,
          ?string $type = 'text/html',
          array ...$extra
      Severity: Minor
      Found in Coroutine/SocketMessage.php - About 1 hr to fix

        Function elements has a Cognitive Complexity of 11 (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/Set.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 open has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          public static function open(string $path, string $flag = 'r', int $mode = \S_IRWXU, $contexts = null)
          {
            if (isset(self::$fileFlags[$flag])) {
              if (self::isUv() && (\strpos($path, '://') === false)) {
                return new Kernel(
        Severity: Minor
        Found in Coroutine/FileSystem.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 file_get has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          function file_get(string $filename)
          {
            $fd = yield file_open($filename, 'r');
            if (\is_resource($fd)) {
              if (file_meta($fd, 'wrapper_type') === 'http') {
        Severity: Minor
        Found in Coroutine/Path.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 addTimeout has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          public function addTimeout($task = null, float $timeout = 0.0, int $tid = null)
          {
            if ($this->isUv()) {
              $interval = (int) \round($timeout * 1000);
              $timer = \uv_timer_init($this->uv);
        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 __construct has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public function __construct($socket = None, $timeout = 1)
          {
            $isSocketOrStream = (!\IS_PHP8)
              ? \get_resource_type($socket)
              : ($socket instanceof \Socket ? 'Socket' : \get_resource_type($socket));
        Severity: Minor
        Found in Coroutine/Misc/Network/Sockets.php - About 1 hr to fix

          Method certificate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public static function certificate(
              string $name = null,
              string $ssl_path = null,
              string $ssl_file = null,
              array $details = []
          Severity: Minor
          Found in Coroutine/Misc/Network/SSLContext.php - About 1 hr to fix

            Method with has 30 lines of code (exceeds 25 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 1 hr to fix

              Method throwable has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                protected static function throwable(\Throwable $error, CoroutineInterface $coroutine)
                {
                  yield;
                  $task = $coroutine->getTask(yield \current_task());
                  $task->setState(
              Severity: Minor
              Found in Coroutine/Kernel.php - About 1 hr to fix

                Method watch has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  public static function watch(string $path, int $watchTask)
                  {
                    if (self::isUv()) {
                      return new Kernel(
                        function (TaskInterface $task, CoroutineInterface $coroutine) use ($path, $watchTask) {
                Severity: Minor
                Found in Coroutine/FileSystem.php - About 1 hr to fix

                  Method setWriter has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    public function setWriter(callable $writer = null, $levels = self::ALL, $interval = 1, callable $formatter = null)
                    {
                      if (empty($formatter)) {
                        $formatter = $this->defaultFormatter;
                      }
                  Severity: Minor
                  Found in Coroutine/Logger/Logger.php - About 1 hr to fix

                    Method run has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      public function run(?\closure $task = null, ...$argv): Futures
                      {
                        if ($this->isClosed())
                          throw new Closed('already closed');
                    
                    
                    Severity: Minor
                    Found in Coroutine/Parallel/Runtime.php - About 1 hr to fix

                      Method interpolate has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        private static function interpolate($string, array $vars)
                        {
                          if (!\preg_match_all("~\{([\w\.]+)\}~", $string, $matches, \PREG_SET_ORDER)) {
                            return $string;
                          }
                      Severity: Minor
                      Found in Coroutine/Logger/Logger.php - About 1 hr to fix

                        Method read has 28 lines of code (exceeds 25 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 1 hr to fix

                          Function assertOpenSSLx509 has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                            protected function assertOpenSSLx509($resource)
                            {
                              if (!\IS_PHP8) {
                                if (!\is_resource($resource)) {
                                  throw new \InvalidArgumentException(\sprintf('Resource expected, got "%s"', \gettype($resource)));
                          Severity: Minor
                          Found in Coroutine/Misc/Network/SSLSockets.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 contents has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                            public static function contents($fd = null, int $size = 256, float $timeout_seconds = 0.5)
                            {
                              if (!\is_resource($fd))
                                return yield \value(false);
                          
                          
                          Severity: Minor
                          Found in Coroutine/FileSystem.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

                          Severity
                          Category
                          Status
                          Source
                          Language