luyadev/luya-module-cms

View on GitHub

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, '/');

Severity: Minor
Found in src/models/Redirect.php - About 45 mins to fix

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;
Severity: Minor
Found in src/widgets/LangSwitcher.php - About 45 mins to fix

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) {
Severity: Minor
Found in src/menu/Query.php - About 45 mins to fix

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 = [])
Severity: Minor
Found in src/models/Log.php - About 35 mins to fix

    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
    Severity: Minor
    Found in src/models/Block.php - About 35 mins to fix

      Function renderTemplate has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              $scope.renderTemplate = function(template, dataVars, cfgVars, block, extras) {
      Severity: Minor
      Found in src/admin/resources/js/cmsadmin.js - About 35 mins to fix

        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();
        Severity: Minor
        Found in src/admin/importers/BlockImporter.php - About 35 mins to fix

        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
        Severity: Minor
        Found in src/tags/PageTag.php - About 35 mins to fix

        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
        Severity: Minor
        Found in src/admin/helpers/MenuHelper.php - About 35 mins to fix

        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) {
        Severity: Minor
        Found in src/models/Nav.php - About 35 mins to fix

        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');
        Severity: Minor
        Found in src/admin/helpers/MenuHelper.php - About 35 mins to fix

        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.");
                }
        Severity: Minor
        Found in src/admin/apis/NavController.php - About 35 mins to fix

        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) {
        Severity: Minor
        Found in src/models/NavItem.php - About 35 mins to fix

        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 = [];
        Severity: Minor
        Found in src/models/NavItemPage.php - About 35 mins to fix

        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 = [];
        Severity: Minor
        Found in src/base/InternalBaseBlock.php - About 35 mins to fix

        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.');
                }
        Severity: Minor
        Found in src/frontend/controllers/PreviewController.php - About 35 mins to fix

        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) {
        Severity: Minor
        Found in src/frontend/views/inline/toolbar.js - About 35 mins to fix

        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.");
                }
        Severity: Minor
        Found in src/frontend/commands/UpdaterController.php - About 35 mins to fix

        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'));
        
        
        Severity: Minor
        Found in tests/src/menu/QueryTest.php - About 35 mins to fix

        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;
        Severity: Major
        Found in src/models/Log.php - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language