symplely/thread_queue

View on GitHub
Threads/Thread.php

Summary

Maintainability
C
1 day
Test Coverage

Thread has 31 functions (exceeds 20 allowed). Consider refactoring.
Open

final class Thread
{
    /** @var array[string|int => int|\UVAsync] */
    protected $threads = [];

Severity: Minor
Found in Threads/Thread.php - About 3 hrs to fix

    File Thread.php has 324 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

      Method create has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function create($tid, callable $task, ...$args): ?TWorker
          {
              $tid = \is_scalar($tid) ? $tid : (int) $tid;
              if (!isset($this->threads[$tid])) {
                  \uv_mutex_lock($this->lock);
      Severity: Minor
      Found in Threads/Thread.php - About 1 hr to fix

        Function join has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function join($tid = null): void
            {
                $isCoroutine = self::isCoroutine($this->loop);
                $isCancelling = !empty($tid) && $this->isCancelled($tid);
                while (!empty($tid) ? ($this->isRunning($tid) || $this->isCancelled($tid)) : !$this->isEmpty()) {
        Severity: Minor
        Found in Threads/Thread.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 handlers has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function handlers($tid): void
            {
                if ($this->isSuccessful($tid)) {
                    if ($this->hasLoop) // @codeCoverageIgnoreStart
                        $this->loop->executeTask($this->success, $tid);
        Severity: Minor
        Found in Threads/Thread.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 triggerError has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function triggerError($tid)
            {
                if (isset($this->exception[$tid])) {
                    $exception = $this->exception[$tid];
                    if ($this->isYield)
        Severity: Minor
        Found in Threads/Thread.php - About 35 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 cancel has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function cancel($tid = null): void
            {
                if (isset($this->status[$tid])) {
                    \uv_mutex_lock($this->lock);
                    $this->status[$tid] = ['cancelled'];
        Severity: Minor
        Found in Threads/Thread.php - About 35 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

        There are no issues that match your filters.

        Category
        Status