luyadev/luya-module-cms

View on GitHub

Showing 326 of 326 total issues

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

                case NavItem::TYPE_MODULE:
                    $typeModel = new NavItemModule();
                    $this->setPostAttribute($typeModel, 'module_name');
                    $this->setPostAttribute($typeModel, 'controller_name');
                    $this->setPostAttribute($typeModel, 'action_name');
Severity: Major
Found in src/admin/apis/NavItemController.php and 1 other location - About 1 hr to fix
src/admin/apis/NavItemController.php on lines 385..396

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 103.

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

        if ($this->is_insertion) {
            return match ($tableName) {
                "cms_nav_item" => Module::t('log_action_insert_cms_nav_item', ['info' => $this->rowDescriber]),
                "cms_nav" => Module::t('log_action_insert_cms_nav', ['info' => $this->rowDescriber]),
                "cms_nav_item_page_block_item" => Module::t('log_action_insert_cms_nav_item_page_block_item', ['info' => $this->rowDescriber]),
Severity: Major
Found in src/models/Log.php and 1 other location - About 1 hr to fix
src/models/Log.php on lines 253..260

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 103.

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 createModuleItem has 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function createModuleItem($navId, $langId, $title, $alias, $moduleName, $description, $controllerName, $actionName, array $actionParams): array|int
Severity: Major
Found in src/models/Nav.php - About 1 hr to fix

    Method actionSaveProperties has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function actionSaveProperties($navId)
        {
            $rows = [];
    
            $doNotDeleteList = [];
    Severity: Minor
    Found in src/admin/apis/NavController.php - About 1 hr to fix

      Method generateItems has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function generateItems($start, $end, $lang)
          {
              $data = [];
              foreach (range($start, $end) as $number) {
                  $data[$number] = [
      Severity: Minor
      Found in tests/src/menu/QueryTest.php - About 1 hr to fix

        Method testActionTags has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function testActionTags()
            {
                PermissionScope::run($this->app, function (PermissionScope $scope) {
                    $scope->createAndAllowRoute('webmodel/nav/tags');
                    $scope->createAndAllowRoute('webmodel/nav/save-tags');
        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

                          $http.post('admin/api-cms-navitemblock/copy-block-from-stack', {
                              copyBlockId: dragged.id,
                              sort_index: 0,
                              prev_id:  dropped.prev_id,
                              placeholder_var : dropped.var,
          Severity: Major
          Found in src/admin/resources/js/cmsadmin.js and 1 other location - About 1 hr to fix
          src/admin/resources/js/cmsadmin.js on lines 1512..1520

          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 57.

          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

                                  $http.get('admin/api-cms-navitem/get-nav-container-name', { params : { navId : $scope.navId }}).then(function(response) {
                                      $scope.container = response.data;
                                  });
          Severity: Major
          Found in src/admin/resources/js/cmsadmin.js and 1 other location - About 1 hr to fix
          src/admin/resources/js/cmsadmin.js on lines 147..149

          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 57.

          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

                                  $http.get('admin/api-cms-navitem/get-nav-item-path', { params : { navId : $scope.navId }}).then(function(response) {
                                      $scope.path = response.data;
                                  });
          Severity: Major
          Found in src/admin/resources/js/cmsadmin.js and 1 other location - About 1 hr to fix
          src/admin/resources/js/cmsadmin.js on lines 150..152

          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 57.

          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

                          $http.post('admin/api-cms-navitempageblockitem/create', {
                              prev_id : dropped.prev_id,
                              sort_index:0, 
                              block_id : dragged.id,
                              placeholder_var : dropped.var,
          Severity: Major
          Found in src/admin/resources/js/cmsadmin.js and 1 other location - About 1 hr to fix
          src/admin/resources/js/cmsadmin.js on lines 1523..1531

          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 57.

          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 luyaBootstrap has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              public function luyaBootstrap(Application $app)
              {
                  if (!$app->request->isConsoleRequest && !$app->request->isAdmin) {
                      if ($app->has('composition') && $app->has('website')) {
                          if (empty($app->composition->hostInfoMapping)) {
          Severity: Minor
          Found in src/frontend/Module.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 renderToolbar has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              public function renderToolbar($event)
              {
                  Yii::info('LUYA CMS Toolbar rendering start', __METHOD__);
          
                  $props = [];
          Severity: Minor
          Found in src/frontend/base/Controller.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 imageUpload has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function imageUpload(string|int|null $value, bool|string $applyFilter = false, $returnObject = false): bool|array|\luya\admin\image\Item
              {
                  if (empty($value)) {
                      return false;
                  }
          Severity: Minor
          Found in src/helpers/BlockHelper.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 createHostInfoMapping has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              public function createHostInfoMapping()
              {
                  $hostInfoMapping = [];
          
                  foreach ($this->loadAllWebsiteData() as $website) {
          Severity: Minor
          Found in src/Website.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 controller has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                      controller : ['$scope', '$http', function($scope, $http) {
          
                          $scope.parent = $scope.$parent.$parent;
                          $scope.navItemId = $scope.parent.item.id;
          
          
          Severity: Minor
          Found in src/admin/resources/js/cmsadmin.js - About 1 hr to fix

            Method getItems has 27 lines of code (exceeds 25 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

              Method run has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function run()
                  {
                      // when the setup timestamp is not yet set, its a fresh installation, therefore skip the 1.0.0 generic block upgrade
                      // otherwise its an existing/upgrading instance which is doing the import command.
                      if (!Config::has(Config::CONFIG_SETUP_COMMAND_TIMESTAMP)) {
              Severity: Minor
              Found in src/admin/importers/BlockImporter.php - About 1 hr to fix

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

                    public function actionMoveAfter($moveItemId, $droppedAfterItemId)
                    {
                        $result = Nav::moveToAfter($moveItemId, $droppedAfterItemId);
                
                        if ($result !== true) {
                Severity: Major
                Found in src/admin/apis/NavItemController.php and 2 other locations - About 1 hr to fix
                src/admin/apis/NavItemController.php on lines 452..462
                src/admin/apis/NavItemController.php on lines 490..500

                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 102.

                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 testBlockEnvOptions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function testBlockEnvOptions()
                    {
                        $block = new TestBlock();
                        $pageObject = new ActiveRecord(); // @TODO specify class
                
                
                Severity: Minor
                Found in tests/src/base/BlockTest.php - About 1 hr to fix

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

                      public function actionMoveBefore($moveItemId, $droppedBeforeItemId)
                      {
                          $result = Nav::moveToBefore($moveItemId, $droppedBeforeItemId);
                  
                          if ($result !== true) {
                  Severity: Major
                  Found in src/admin/apis/NavItemController.php and 2 other locations - About 1 hr to fix
                  src/admin/apis/NavItemController.php on lines 471..481
                  src/admin/apis/NavItemController.php on lines 490..500

                  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 102.

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language