Showing 38 of 43 total issues
Function function
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function: (params, onError) => {
params.tokens.filter(function filterToken(token) {
return token.type === "heading_open";
}).forEach(function forToken(token) {
if (token.tag === "h2") {
- 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 assertClassUsesTraits
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function assertClassUsesTraits($class, $expected_traits, string $message = ''): void
{
/**
* Returns all traits used by a trait and its traits.
*
Method dataGet
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function dataGet(mixed $target, string|array|int|null $key, mixed $default = null): mixed
{
if ($key === null) {
return $target;
}
Method dataToArray
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function dataToArray(mixed $items): mixed
{
if (is_object($items)) {
if ($items instanceof JsonSerializable) {
return static::dataToArray($items->jsonSerialize());
Method sortByMany
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function sortByMany(array $comparisons = []): static
{
$items = $this->elements;
uasort(
Method groupBy
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function groupBy(callable|array|string $groupBy, bool $preserveKeys = false): static
{
if (is_array($groupBy) && !$this->useAsCallable($groupBy)) {
$nextGroups = $groupBy;
Function get
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function get(mixed $array, string|int|null $key, mixed $default = null, string $separator = '.'): mixed
{
if (!static::accessible($array)) {
return value($default);
}
- 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 random
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function random(array $array, ?int $number = null, bool $preserveKeys = false): mixed
{
$requested = $number ?? 1;
$count = count($array);
- 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 initLanguageMap
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private static function initLanguageMap(string $language = ''): void
{
if (count(self::$map) > 0 && (($language === '') || ($language === self::$language))) {
return;
}
- 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 value($default);
Avoid too many return
statements within this method. Open
return $array;
Avoid too many return
statements within this method. Open
return (array)$items;
Avoid too many return
statements within this method. Open
return (array)$items->jsonSerialize();
Avoid too many return
statements within this method. Open
return value($default);
Avoid too many return
statements within this method. Open
return $target;
Function sortBy
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function sortBy(array|string|callable $callback, int $options = SORT_REGULAR, bool $descending = false)
{
if (is_array($callback) && !is_callable($callback)) {
return $this->sortByMany($callback);
}
- 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 remoteStaticCall
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function remoteStaticCall(object|string|null $class, string $method, mixed ...$params): mixed
{
if (!$class) {
return null;
}
- 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 remoteStaticCallOrTrow
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function remoteStaticCallOrTrow(object|string|null $class, string $method, mixed ...$params): mixed
{
if (!$class) {
throw new RuntimeException('Target Class is absent');
}
- 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"