Function checkRoute
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public static function checkRoute($route, $params = [], $user = null)
{
$config = Configs::instance();
$r = static::normalizeRoute($route, $config->advanced);
if ($config->onlyRegisteredRoute && !isset(static::getRegisteredRoutes()[$r])) {
- 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 getDefaultRoutes
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
protected static function getDefaultRoutes()
{
if (self::$_defaultRoutes === null) {
$manager = Configs::authManager();
$roles = $manager->defaultRoles;
- 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 getRoutesByUser
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static function getRoutesByUser($userId)
{
if (!isset(self::$_userRoutes[$userId])) {
$cache = Configs::cache();
if ($cache && ($routes = $cache->get([__METHOD__, $userId])) !== 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
Method checkRoute
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function checkRoute($route, $params = [], $user = null)
{
$config = Configs::instance();
$r = static::normalizeRoute($route, $config->advanced);
if ($config->onlyRegisteredRoute && !isset(static::getRegisteredRoutes()[$r])) {
Function filterRecursive
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected static function filterRecursive($items, $user)
{
$result = [];
foreach ($items as $i => $item) {
$url = ArrayHelper::getValue($item, 'url', '#');
- 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 true;
Avoid too many return
statements within this method. Open
return isset($routes['/*']);
Avoid too many return
statements within this method. Open
return true;
Function getRegisteredRoutes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function getRegisteredRoutes()
{
if (self::$_routes === null) {
self::$_routes = [];
$manager = Configs::authManager();
- 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 filterActionColumn
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function filterActionColumn($buttons = [], $user = null)
{
if (is_array($buttons)) {
$result = [];
foreach ($buttons as $button) {
- 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 normalizeRoute
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected static function normalizeRoute($route, $advanced = false)
{
if ($route === '') {
$normalized = '/' . Yii::$app->controller->getRoute();
} elseif (strncmp($route, '/', 1) === 0) {
- 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"