luyadev/luya-module-cms

View on GitHub

Showing 326 of 326 total issues

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

<?php

namespace luya\cms\base;

/**
Severity: Major
Found in src/base/BlockCfg.php and 1 other location - About 1 hr to fix
src/base/BlockVar.php on lines 1..26

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

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

        $scope.dropItem = function(dragged,dropped,position,element) {
            var sortIndex = $scope.$index;
            
            if (position == 'bottom') {
                sortIndex = sortIndex + 1;
Severity: Minor
Found in src/admin/resources/js/cmsadmin.js - About 1 hr 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

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

        Function getItem has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                $scope.getItem = function(langId, navId) {
                    $http({
                        url: 'admin/api-cms-navitem/nav-lang-item',
                        method: "GET",
                        params: { langId : langId, navId : navId }
        Severity: Minor
        Found in src/admin/resources/js/cmsadmin.js - About 1 hr to fix

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

              public function createPageItem($navId, $langId, $title, $alias, $layoutId, $description): array|int
              {
                  $_errors = [];
          
                  $navItem = new NavItem();
          Severity: Minor
          Found in src/models/Nav.php - About 1 hr to fix

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

                            $scope.$watch('data.alias', function(n, o) {
                                if (n!=o && n!=null) {
                                    $scope.data.alias = $filter('slugify')(n);
                                }
                            });
            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 1289..1293

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

            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

                    $scope.$watch('itemCopy.alias', function(n, o) {
                        if (n!=o && n!=null) {
                            $scope.itemCopy.alias = $filter('slugify')(n);
                        }
                    });
            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 230..234

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

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

                        controller : ['$scope', '$http', function($scope, $http) {
            
                            $scope.modules = [];
                            $scope.controllers = [];
                            $scope.actions = [];
            Severity: Minor
            Found in src/admin/resources/js/cmsadmin.js - About 1 hr to fix

              Method testActionDeepPageCopyAsTemplateError has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

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

                Method testNavItemForPageVersions has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function testNavItemForPageVersions()
                    {
                        $navItemFixture = $this->createCmsNavItemFixture([
                            1 => [
                                'id' => 1,
                Severity: Minor
                Found in tests/src/models/NavItemPageTest.php - About 1 hr to fix

                  Method testRegisterCssAndJs has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function testRegisterCssAndJs()
                      {
                          // Simulate already registered js
                          Yii::$app->view->js = [
                              View::POS_READY => [
                  Severity: Minor
                  Found in tests/src/base/PhpBlockViewTest.php - About 1 hr to fix

                    Method testFindWebsiteContainer has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function testFindWebsiteContainer()
                        {
                            PageScope::run($this->app, function (PageScope $scope) {
                                $this->createAdminGroupFixture(1);
                                $this->createAdminUserFixture();
                    Severity: Minor
                    Found in tests/src/models/NavContainerTest.php - About 1 hr to fix

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

                          public function createPageFromDraft($parentNavId, $navContainerId, $langId, $title, $alias, $description, $fromDraftNavId, $isDraft = false): bool|array
                          {
                              if (!$isDraft && empty($isDraft) && !is_numeric($isDraft)) {
                                  $isDraft = 0;
                              }
                      Severity: Minor
                      Found in src/models/Nav.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 imageArrayUpload has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public static function imageArrayUpload(string|int|null|array $value, bool|string $applyFilter = false, $returnObject = false)
                          {
                              if (!empty($value) && is_array($value)) {
                                  $data = [];
                      
                      
                      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 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

                      Method createModule has 10 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

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

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

                            public function rules()
                            {
                                return [
                                    [['json_config_values', 'json_config_cfg_values'], function ($attribute, $params) {
                                        // if its not an array, the attribute is not dirty and has not to be serialized from input.
                        Severity: Minor
                        Found in src/models/NavItemPageBlockItem.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 createRedirect has 10 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            public function createRedirect($parentNavId, $navContainerId, $langId, $title, $alias, $redirectType, $redirectTypeValue, $description, $redirectTypeTarget, $anchor = null): array|int
                        Severity: Major
                        Found in src/models/Nav.php - About 1 hr to fix

                          Function run has a Cognitive Complexity of 11 (exceeds 5 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

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language