Function gather
has a Cognitive Complexity of 158 (exceeds 5 allowed). Consider refactoring. Open
public static function gather(...$taskId)
{
return new Kernel(
function (TaskInterface $task, CoroutineInterface $coroutine) use ($taskId) {
$gatherCount = self::$gatherCount;
- Read upRead up
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 Kernel.php
has 1075 lines of code (exceeds 250 allowed). Consider refactoring. Wontfix
<?php
declare(strict_types=1);
namespace Async;
Method gather
has 218 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
public static function gather(...$taskId)
{
return new Kernel(
function (TaskInterface $task, CoroutineInterface $coroutine) use ($taskId) {
$gatherCount = self::$gatherCount;
Kernel
has 40 functions (exceeds 20 allowed). Consider refactoring. Wontfix
final class Kernel
{
protected $callback;
protected static $gatherCount = 0;
protected static $gatherShouldError = true;
Function asyncWith
has a Cognitive Complexity of 34 (exceeds 5 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;
- Read upRead up
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 cancelTask
has a Cognitive Complexity of 22 (exceeds 5 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);
- Read upRead up
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 addFuture
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function addFuture(
$command,
$timeout = 0,
bool $display = false,
$channel = null,
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)) {
- Read upRead up
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;
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);
Method await
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
public static function await(string $label, ...$arguments)
{
switch ($label) {
case 'sleep':
case 'sleep_for':
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;
Function away
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function away($label, ...$args)
{
if (\is_string($label) && Co::isFunction($label)) {
return Kernel::createTask(Co::getFunction($label)(...$args), true);
}
- Read upRead up
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 throwable
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected static function throwable(\Throwable $error, CoroutineInterface $coroutine)
{
yield;
$task = $coroutine->getTask(yield \current_task());
$task->setState(
- Read upRead up
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) {
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)) {
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(
Function await
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function await(string $label, ...$arguments)
{
switch ($label) {
case 'sleep':
case 'sleep_for':
- Read upRead up
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 away
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
public static function away($label, ...$args)
{
if (\is_string($label) && Co::isFunction($label)) {
return Kernel::createTask(Co::getFunction($label)(...$args), true);
}
Method addFuture
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
$command,
$timeout = 0,
bool $display = false,
$channel = null,
$channelTask = null,
Method spawnTask
has 8 arguments (exceeds 4 allowed). Consider refactoring. Wontfix
$callable,
$timeout = 0,
bool $display = false,
$channel = null,
$channelTask = null,
Function joinTask
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function joinTask(int $tid)
{
return new Kernel(
function (TaskInterface $task, CoroutineInterface $coroutine) use ($tid) {
$join = $coroutine->getTask($tid);
- Read upRead up
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 gatherController
has 7 arguments (exceeds 4 allowed). Consider refactoring. Wontfix
string $isCustomSate = 'n/a',
?callable $onPreComplete = null,
?callable $onProcessing = null,
?callable $onCompleted = null,
?callable $onError = null,
Function asyncFor
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function asyncFor(AsyncIterator $task, \Closure $as)
{
while (true) {
try {
$item = yield $task->current();
- Read upRead up
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. Wontfix
if ($subCount == 0)
break;
Function progressTask
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function progressTask(callable $handler)
{
return Kernel::away(function () use ($handler) {
yield;
while (true) {
- Read upRead up
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 too many return
statements within this method. Open
return yield Kernel::gather(...$arguments);
Avoid too many return
statements within this method. Open
return yield $misc_function(...$arguments);
Avoid too many return
statements within this method. Open
return yield $file_function(...$arguments);
Avoid too many return
statements within this method. Open
return @$label(...$arguments);
Avoid too many return
statements within this method. Open
return yield Co::getFunction($label)(...$arguments);
Avoid too many return
statements within this method. Open
return yield Kernel::spawnTask($system, 0, $display);
Avoid too many return
statements within this method. Open
return yield awaitable_future(function () use ($system, $display) {
return Kernel::addFuture($system, 0, $display);
});
Avoid too many return
statements within this method. Open
return yield $function(...$arguments);
Function __timeoutAfter
has a Cognitive Complexity of 6 (exceeds 5 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;
- Read upRead up
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"