Showing 209 of 236 total issues
Function commit
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function commit()
{
if (\is_array($this->loggerTaskId) && (\count($this->loggerTaskId) > 0)) {
foreach (\range(0, \count($this->loggerTaskId)) as $nan)
yield;
- 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 listen
has a Cognitive Complexity of 14 (exceeds 5 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) {
- 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 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 run
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function run()
{
if ($this->beforeFirstYield) {
$this->beforeFirstYield = false;
return ($this->coroutine instanceof \Generator)
- 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 __construct
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function __construct()
{
$this->maxTaskId = Co::getUnique('dirty') === 1 ? Co::getUnique('max') : \random_int(10000, 9999999999);
Co::reset();
Co::setLoop($this);
- 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 14 (exceeds 5 allowed). Consider refactoring. Open
public function cancelTask(int $tid, $customState = null, string $errorMessage = 'Invalid task ID!')
{
if (!isset($this->taskMap[$tid])) {
return 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"
Further reading
Similar blocks of code found in 2 locations. Consider refactoring. Open
public static function peer($handle)
{
if ($handle instanceof \UVTcp) {
$peer = \uv_tcp_getpeername($handle);
return $peer['address'] . ':' . $peer['port'];
- Read upRead up
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 115.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public static function local($handle)
{
if ($handle instanceof \UVTcp) {
$local = \uv_tcp_getsockname($handle);
return $local['address'] . ':' . $local['port'];
- Read upRead up
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 115.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method executeFiber
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function executeFiber(Fiber $fiber)
{
// Skip and reschedule, if `fiber` in suspend state
if ($fiber->isSuspended())
return $this->scheduleFiber($fiber);
Function elements
has a Cognitive Complexity of 13 (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;
- 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 interpolate
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private static function interpolate($string, array $vars)
{
if (!\preg_match_all("~\{([\w\.]+)\}~", $string, $matches, \PREG_SET_ORDER)) {
return $string;
}
- 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 connect
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function connect(string $scheme, string $address, int $port, $data = null)
{
return new Kernel(
function (TaskInterface $task, CoroutineInterface $coroutine) use ($scheme, $address, $port, $data) {
$callback = function ($client, $status) use ($task, $coroutine) {
Method create_default_context
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function create_default_context(
string $purpose,
?string $name = None,
$context = [],
?string $capath = None,
Method adding
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function adding(?\closure $future = null, ?string $include = null, ...$args): FutureInterface
{
$defined = Globals::get();
if (!\is_callable($future) && !$future instanceof FutureInterface) {
Method parse
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parse($headers)
{
$this->headers = [];
$this->parameters = [];
$this->path = '';
Method addTimeout
has 37 lines of code (exceeds 25 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);
Method accept
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function accept($server)
{
if (self::isUv() && $server instanceof \UV) {
return yield new Kernel(
function (TaskInterface $task, CoroutineInterface $coroutine) use ($server) {
Function result
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function result()
{
if ($this->isCompleted()) {
$result = $this->result;
if ($this->customData instanceof FutureInterface)
- 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 setWriter
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function setWriter(callable $writer = null, $levels = self::ALL, $interval = 1, callable $formatter = null)
{
if (empty($formatter)) {
$formatter = $this->defaultFormatter;
}
- 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"