luyadev/luya-module-cms

View on GitHub
src/models/NavItemPage.php

Summary

Maintainability
F
3 days
Test Coverage
F
50%

Function renderPlaceholderRecursive has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
Open

    private function renderPlaceholderRecursive($navItemPageId, $placeholderVar, $prevId, $layoutBlockInstance = null)
    {
        $string = '';
        $i = 0;
        $equalIndex = 1;
Severity: Minor
Found in src/models/NavItemPage.php - About 1 day 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

File NavItemPage.php has 370 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace luya\cms\models;

use luya\cms\admin\Module;
Severity: Minor
Found in src/models/NavItemPage.php - About 4 hrs to fix

    Method renderPlaceholderRecursive has 83 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function renderPlaceholderRecursive($navItemPageId, $placeholderVar, $prevId, $layoutBlockInstance = null)
        {
            $string = '';
            $i = 0;
            $equalIndex = 1;
    Severity: Major
    Found in src/models/NavItemPage.php - About 3 hrs to fix

      NavItemPage has 23 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class NavItemPage extends NavItemType implements NavItemTypeInterface, ViewContextInterface
      {
          use CacheableTrait;
      
          /**
      Severity: Minor
      Found in src/models/NavItemPage.php - About 2 hrs to fix

        Method getBlockItem has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function getBlockItem(NavItemPageBlockItem $blockItem, NavItemPage $navItemPage, array $envOptions = [])
            {
                // if the block relation could be found, return false.
                if (!$blockItem->block) {
                    return false;
        Severity: Major
        Found in src/models/NavItemPage.php - About 2 hrs to fix

          Method getPlaceholder has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function getPlaceholder($placeholderVar, $prevId, NavItemPage $navItemPage)
              {
                  $nav_item_page_block_item_data = NavItemPageBlockItem::find()
                      ->select(['id', 'block_id', 'json_config_values', 'json_config_cfg_values', 'nav_item_page_id', 'is_dirty', 'is_hidden', 'variation'])
                      ->where(['prev_id' => $prevId, 'nav_item_page_id' => $navItemPage->id, 'placeholder_var' => $placeholderVar])
          Severity: Minor
          Found in src/models/NavItemPage.php - About 1 hr to fix

            Function getContentAsArray has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getContentAsArray()
                {
                    //$nav_item_page = (new \yii\db\Query())->select('*')->from('cms_nav_item_page t1')->leftJoin('cms_layout', 'cms_layout.id=t1.layout_id')->where(['t1.id' => $this->id])->one();
                    $nav_item_page = $this;
            
            
            Severity: Minor
            Found in src/models/NavItemPage.php - About 1 hr 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 getBlockItem has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function getBlockItem(NavItemPageBlockItem $blockItem, NavItemPage $navItemPage, array $envOptions = [])
                {
                    // if the block relation could be found, return false.
                    if (!$blockItem->block) {
                        return false;
            Severity: Minor
            Found in src/models/NavItemPage.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 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 getContent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getContent()
                {
                    if (!$this->layout) {
                        throw new InvalidConfigException("Unable to find the requested cms layout '{$this->layout_id}' for nav item page id '{$this->id}'. Make sure your page does not have an old inactive/deleted cms layout selected.");
                    }
            Severity: Minor
            Found in src/models/NavItemPage.php - About 25 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

            There are no issues that match your filters.

            Category
            Status