luyadev/luya-module-cms

View on GitHub

Showing 209 of 326 total issues

Method testSetUrlRuleParamsForI18nSlugUrlRules has 98 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testSetUrlRuleParamsForI18nSlugUrlRules()
    {
        $langFixture = $this->createAdminLangFixture([
            'de' => [
                'id' => 1,
Severity: Major
Found in tests/src/widgets/LangSwitcherSqliteTest.php - About 3 hrs to fix

    Method testModuleBlock has 90 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function testModuleBlock()
        {
            $tpl = <<<'EOT'
    <?php
    
    
    Severity: Major
    Found in tests/src/frontend/commands/BlockControllerTest.php - About 3 hrs to fix

      File NavItem.php has 316 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace luya\cms\models;
      
      use luya\admin\base\GenericSearchInterface;
      Severity: Minor
      Found in src/models/NavItem.php - About 3 hrs to fix

        Function getItems has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function getItems()
            {
                if (self::$items === null) {
                    $items = Nav::find()
                        ->select(['cms_nav.id', 'nav_item_id' => 'cms_nav_item.id', 'nav_container_id', 'parent_nav_id', 'is_hidden', 'layout_file', 'is_offline', 'is_draft', 'is_home', 'cms_nav_item.title'])
        Severity: Minor
        Found in src/admin/helpers/MenuHelper.php - About 3 hrs 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 actionCreate has 89 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function actionCreate()
            {
                if (empty($this->type)) {
                    Console::clearScreenBeforeCursor();
                    $this->type = $this->select('Do you want to create an app or module Block?', [
        Severity: Major
        Found in src/frontend/commands/BlockController.php - About 3 hrs to fix

          Method testAppBlock has 89 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function testAppBlock()
              {
                  $tpl = <<<'EOT'
          <?php
          
          
          Severity: Major
          Found in tests/src/frontend/commands/BlockControllerTest.php - About 3 hrs to fix

            File BlockPlaceholderIterationTest.php has 313 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            namespace cmstests\data\blocks;
            
            use cmstests\CmsFrontendTestCase;
            Severity: Minor
            Found in tests/src/base/BlockPlaceholderIterationTest.php - About 3 hrs to fix

              NavItem has 29 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class NavItem extends ActiveRecord implements GenericSearchInterface
              {
                  public const TYPE_PAGE = 1;
              
                  public const TYPE_MODULE = 2;
              Severity: Minor
              Found in src/models/NavItem.php - About 3 hrs to fix

                Function actionCreate has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function actionCreate()
                    {
                        if (empty($this->type)) {
                            Console::clearScreenBeforeCursor();
                            $this->type = $this->select('Do you want to create an app or module Block?', [
                Severity: Minor
                Found in src/frontend/commands/BlockController.php - About 3 hrs 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 importLayoutFile has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function importLayoutFile($file, $aliased, $themeName = null)
                    {
                        if (!file_exists($file)) {
                            return false;
                        }
                Severity: Minor
                Found in src/admin/importers/CmslayoutImporter.php - About 3 hrs 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

                InjectItem has 28 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class InjectItem extends BaseObject implements InjectItemInterface
                {
                    /**
                     * @var integer The user id who created this page.
                     */
                Severity: Minor
                Found in src/menu/InjectItem.php - About 3 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

                    Function renderItem has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function renderItem($navItemId, $appendix = null, bool|int $setNavItemTypeId = false)
                        {
                            $model = NavItem::find()->where(['id' => $navItemId])->with(['nav'])->one();
                    
                            if (!$model) {
                    Severity: Minor
                    Found in src/frontend/base/Controller.php - About 3 hrs 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 testRegisterDefaultVariations has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function testRegisterDefaultVariations()
                        {
                            $this->app->getModule('cmsadmin')->blockVariations = [
                                TestingBlock::variations()
                                    ->add('idf', 'My Test')
                    Severity: Major
                    Found in tests/src/base/BlockVariationRegisterTest.php - About 3 hrs to fix

                      Method testRenderPlaceholderIteration has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function testRenderPlaceholderIteration()
                          {
                              $this->app->setComponents([
                                       'db' => [
                                           'class' => 'yii\db\Connection',
                      Severity: Major
                      Found in tests/src/base/BlockPlaceholderIterationTest.php - About 3 hrs to fix

                        File InternalBaseBlock.php has 297 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        <?php
                        
                        namespace luya\cms\base;
                        
                        use luya\admin\base\TypesInterface;
                        Severity: Minor
                        Found in src/base/InternalBaseBlock.php - About 3 hrs to fix

                          Method renderItem has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function renderItem($navItemId, $appendix = null, bool|int $setNavItemTypeId = false)
                              {
                                  $model = NavItem::find()->where(['id' => $navItemId])->with(['nav'])->one();
                          
                                  if (!$model) {
                          Severity: Major
                          Found in src/frontend/base/Controller.php - About 3 hrs to fix

                            Method testActionToggleHome has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function testActionToggleHome()
                                {
                                    PermissionScope::run($this->app, function (PermissionScope $scope) {
                                        $this->createAdminLangFixture();
                                        $this->createCmsNavItemRedirectFixture();
                            Severity: Major
                            Found in tests/src/admin/apis/NavControllerTest.php - About 3 hrs to fix

                              Function actionDataBlocks has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function actionDataBlocks()
                                  {
                                      $favs = Yii::$app->adminuser->identity->setting->get("blockfav", []);
                                      $groups = [];
                                      foreach (BlockGroup::find()->with(['blocks'])->all() as $blockGroup) {
                              Severity: Minor
                              Found in src/admin/apis/AdminController.php - About 2 hrs 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 importLayoutFile has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  protected function importLayoutFile($file, $aliased, $themeName = null)
                                  {
                                      if (!file_exists($file)) {
                                          return false;
                                      }
                              Severity: Major
                              Found in src/admin/importers/CmslayoutImporter.php - About 2 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language