luyadev/luya-module-cms

View on GitHub

Showing 326 of 326 total issues

Similar blocks of code found in 22 locations. Consider refactoring.
Open

            118 =>
            [
                    'id' => '118',
                    'nav_id' => '23',
                    'lang' => 'fr',
Severity: Major
Found in tests/src/menu/_dataFrArray.php and 21 other locations - About 2 hrs to fix
tests/src/menu/_dataFrArray.php on lines 54..78
tests/src/menu/_dataFrArray.php on lines 79..103
tests/src/menu/_dataFrArray.php on lines 153..177
tests/src/menu/_dataFrArray.php on lines 203..227
tests/src/menu/_dataFrArray.php on lines 228..252
tests/src/menu/_dataFrArray.php on lines 253..277
tests/src/menu/_dataFrArray.php on lines 278..302
tests/src/menu/_dataFrArray.php on lines 303..327
tests/src/menu/_dataFrArray.php on lines 328..352
tests/src/menu/_dataFrArray.php on lines 353..377
tests/src/menu/_dataFrArray.php on lines 378..402
tests/src/menu/_dataFrArray.php on lines 403..427
tests/src/menu/_dataFrArray.php on lines 428..452
tests/src/menu/_dataFrArray.php on lines 453..477
tests/src/menu/_dataFrArray.php on lines 503..527
tests/src/menu/_dataFrArray.php on lines 528..552
tests/src/menu/_dataFrArray.php on lines 553..577
tests/src/menu/_dataFrArray.php on lines 578..602
tests/src/menu/_dataFrArray.php on lines 603..627
tests/src/menu/_dataFrArray.php on lines 653..677
tests/src/menu/_dataFrArray.php on lines 678..702

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 122.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method testRenderFrontend has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testRenderFrontend()
    {
        $this->createAdminLangFixture([
            1 => [
                'id' => 1,
Severity: Major
Found in tests/src/frontend/blocks/MirrorLanguageBlockTest.php - About 2 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                112 =>
                [
                        'id' => '112',
                        'nav_id' => '22',
                        'lang' => 'fr',
    Severity: Major
    Found in tests/src/menu/_dataFrArray.php and 1 other location - About 1 hr to fix
    tests/src/menu/_dataFrArray.php on lines 30..53

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 120.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                103 =>
                [
                        'id' => '103',
                        'nav_id' => '2',
                        'lang' => 'fr',
    Severity: Major
    Found in tests/src/menu/_dataFrArray.php and 1 other location - About 1 hr to fix
    tests/src/menu/_dataFrArray.php on lines 104..127

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 120.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method loadWebsiteLanguageContainer has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function loadWebsiteLanguageContainer($langShortCode)
        {
            $hostName = $this->request->hostName;
            $cacheKey = $this->_cachePrefix.$hostName.$langShortCode;
    
    
    Severity: Minor
    Found in src/Menu.php - About 1 hr to fix

      Function actionGetNavItemPath has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public function actionGetNavItemPath($navId)
          {
              $data = "";
              $node = NavItem::find()->where(['nav_id' => $navId])->one();
              if ($node) {
      Severity: Minor
      Found in src/admin/apis/NavItemController.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 getLink has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getLink()
          {
              // take care of redirect
              if ($this->getType() === 3 && !empty($this->redirectMapData('value'))) {
                  // generate convert object to determine correctn usage.
      Severity: Minor
      Found in src/menu/Item.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 run has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public function run()
          {
              $currentLang = Yii::$app->composition['langShortCode'];
      
              $rule = Yii::$app->menu->currentUrlRule;
      Severity: Minor
      Found in src/widgets/LangSwitcher.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

      Method ngRestAttributeTypes has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function ngRestAttributeTypes()
          {
              return [
                  'name' => 'text',
                  'host' => 'slug',
      Severity: Minor
      Found in src/models/Website.php - About 1 hr to fix

        Method copyPageItem has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function copyPageItem(NavItem $targetNavItem)
            {
                if ($this->nav_item_type !== self::TYPE_PAGE) {
                    return false;
                }
        Severity: Minor
        Found in src/models/NavItem.php - About 1 hr to fix

          Method actionCleanup has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function actionCleanup()
              {
                  // return all pages with deleted items
                  $navIds = Nav::find()->where(['is_deleted' => true])->select(['id'])->column();
          
          
          Severity: Minor
          Found in src/frontend/commands/PageController.php - About 1 hr to fix

            Method getItems has 44 lines of code (exceeds 25 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 1 hr to fix

              Method testDelete has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function testDelete()
                  {
                      PermissionScope::run($this->app, function (PermissionScope $scope) {
                          $this->createAdminLangFixture();
                          $this->createCmsWebsiteFixture([
              Severity: Minor
              Found in tests/src/admin/apis/NavControllerTest.php - About 1 hr to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    public function copyRedirectItem(NavItem $targetNavItem)
                    {
                        if ($this->nav_item_type !== self::TYPE_REDIRECT) {
                            return false;
                        }
                Severity: Major
                Found in src/models/NavItem.php and 1 other location - About 1 hr to fix
                src/models/NavItem.php on lines 478..497

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 116.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    public function copyModuleItem(NavItem $targetNavItem)
                    {
                        if ($this->nav_item_type !== self::TYPE_MODULE) {
                            return false;
                        }
                Severity: Major
                Found in src/models/NavItem.php and 1 other location - About 1 hr to fix
                src/models/NavItem.php on lines 506..525

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 116.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                    private function getItems(NavContainer $container, $parentNavId = 0, $parentGroup = [], $index = 1)
                    {
                        $navs = $container->getNavs()->andWhere(['parent_nav_id' => $parentNavId])->all();
                
                        foreach ($navs as $nav) {
                Severity: Minor
                Found in src/admin/apis/MenuController.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 loadInheritanceData has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    private static function loadInheritanceData($parentNavId = 0, $fromInheritNode = false)
                    {
                        // get items from singleton object
                        $items = self::getNavItems()[$parentNavId] ?? [];
                        foreach ($items as $item) {
                Severity: Minor
                Found in src/admin/helpers/MenuHelper.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 resolveCurrent has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function resolveCurrent()
                    {
                        $requestPath = $this->request->get('path', null);
                
                        if (empty($requestPath)) {
                Severity: Minor
                Found in src/Menu.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

                Method createPage has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function createPage($parentNavId, $navContainerId, $langId, $title, $alias, $layoutId, $description, $isDraft = false): array|int
                    {
                        $_errors = [];
                
                        $nav = $this;
                Severity: Minor
                Found in src/models/Nav.php - About 1 hr to fix

                  Function initializer has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          function initializer() {
                              $scope.navData = $filter('filter')($scope.menuData.items, {id: $scope.id}, true)[0];
                              if ($scope.navData == undefined) {
                                  $scope.isDraft = true;
                              } else {
                  Severity: Minor
                  Found in src/admin/resources/js/cmsadmin.js - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language