Showing 209 of 326 total issues
Function pathMatcher
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function pathMatcher($input, $catchPath): bool|string
{
// ensure request path is prefix with slash
$requestPath = '/'.ltrim($input, '/');
- 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 generateHtml
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function generateHtml($href, $isActive, $lang)
{
if (!array_key_exists($href, static::$registerLinkTags)) {
$this->view->registerLinkTag(['rel' => 'alternate', 'hreflang' => $lang['short_code'], 'href' => $href]);
static::$registerLinkTags[$href] = 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 where
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function where(array $args)
{
if (ArrayHelper::isAssociative($args, false)) {
// ensure: ['container' => 'default', 'parent_nav_id' => 0] is possible
foreach ($args as $key => $value) {
- 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 add
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function add($type, array $message, $tableName, $rowId = 0, array $additionalData = [])
Method createObject
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function createObject($class, $blockId, $id, $context, NavItemPage $pageObject = null): false|\luya\cms\base\BlockInterface
Function renderTemplate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$scope.renderTemplate = function(template, dataVars, cfgVars, block, extras) {
Function saveBlock
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function saveBlock($fullClassName)
{
// ensure all classes start with trailing slash class name definition like `\foo\bar\Class`
$fullClassName = '\\' . ltrim($fullClassName, '\\');
$model = Block::find()->where(['class' => $fullClassName])->one();
- 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 parse
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function parse($value, $sub)
{
$page = Nav::findOne(['id' => $value]);
// verify if the page is of type content
- 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 navGroupInheritanceNode
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function navGroupInheritanceNode($navId, Group $group)
{
// default defintion is false
$definition = false;
// see if permission data for group exists, foreach items and set if match
- 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 checkDuplicateAlias
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function checkDuplicateAlias($currentNavId, $parentNavId)
{
$currentNavItems = NavItem::find()->where(['nav_id' => $currentNavId])->asArray()->all();
foreach (self::find()->where(['parent_nav_id' => $parentNavId, 'is_deleted' => false])->andWhere(['<>', 'id', $currentNavId])->asArray()->all() as $item) {
foreach ($currentNavItems as $currentNavItem) {
- 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 checkUserWebsitePermissions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function checkUserWebsitePermissions(array $website)
{
/** @var User $user */
$user = Yii::$app->adminuser->identity;
$userGroupIds = ArrayHelper::getColumn($user->groups, 'id');
- 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 actionDelete
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function actionDelete($navId)
{
if (!Yii::$app->adminuser->canRoute(Module::ROUTE_PAGE_DELETE)) {
throw new ForbiddenHttpException("Unable to remove this page due to permission restrictions.");
}
- 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 getType
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getType(): \luya\cms\models\NavItemPage|\luya\cms\models\NavItemModule|\luya\cms\models\NavItemRedirect|bool
{
if ($this->_type === null) {
// what kind of item type are we looking for
if ($this->nav_item_type == self::TYPE_PAGE) {
- 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 copyBlocks
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function copyBlocks($fromPageId, $toPageId)
{
$pageBlocks = NavItemPageBlockItem::find()->where(['nav_item_page_id' => $fromPageId])->asArray(true)->all();
$idLink = [];
- 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 getConfigPlaceholdersExport
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getConfigPlaceholdersExport()
{
$array = array_key_exists('placeholders', $this->config()) ? $this->config()['placeholders'] : [];
$holders = [];
- 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 actionIndex
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function actionIndex($itemId, $version = false, $date = false): \yii\web\Response|string
{
if (Yii::$app->adminuser->isGuest) {
throw new ForbiddenHttpException('Unable to see the preview page, session expired or not logged in.');
}
- 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 set
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
set: function(name, value, days)
{
var domain, domainParts, date, expires, host;
if (days) {
- 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 actionClasses
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function actionClasses()
{
if (Config::has('rc1_block_classes_renameing')) {
return $this->outputError("You already have run the classes updater, so your system should be up-to-date already.");
}
- 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 testContainerSelector
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function testContainerSelector()
{
Yii::$app->composition['langShortCode'] = 'fr';
Yii::$app->menu->setLanguageContainer('fr', include('_dataFrArray.php'));
- 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;