luyadev/luya-module-cms

View on GitHub

Showing 326 of 326 total issues

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

    public function actionSaveProperties($navId)
    {
        $rows = [];

        $doNotDeleteList = [];
Severity: Minor
Found in src/admin/apis/NavController.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 findOneByHostName has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function findOneByHostName($hostName): array|bool
    {
        $cache = $this->getHasCache($hostName);
        if ($cache) {
            return $cache;
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 getKeywords has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function getKeywords()
    {
        if ($this->_keywords === null) {
            if (empty($this->itemArray['keywords'])) {
                $this->_keywords = [];
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

Method getRowDescriber has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getRowDescriber()
    {
        if (!empty($this->row_id)) {
            switch (StorageFile::cleanBaseTableName($this->table_name)) {
                case "cms_nav":
Severity: Minor
Found in src/models/Log.php - About 1 hr to fix

    Method ensureInputValues has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function ensureInputValues($event)
        {
            // sort index fixture
    
            if (!$this->isNewRecord) {
    Severity: Minor
    Found in src/models/NavItemPageBlockItem.php - About 1 hr to fix

      Method getConfigArray has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getConfigArray()
          {
              return [
                  'id' => 'basetestcase',
                  'basePath' => dirname(__DIR__),
      Severity: Minor
      Found in tests/CmsConsoleTestCase.php - About 1 hr to fix

        Method testImportLayoutAndChangeAfterwardsIssue337 has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function testImportLayoutAndChangeAfterwardsIssue337()
            {
                $this->createCmsLayoutFixture();
                $controller = new ImportController('import-controller', $this->app);
                $importer = new CmslayoutImporter($controller, $this->app->getModule('cmsadmin'));
        Severity: Minor
        Found in tests/src/admin/importers/CmslayoutImporterTest.php - About 1 hr to fix

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

              public function testColumn()
              {
                  PageScope::run($this->app, function (PageScope $scope) {
                      $scope->createAdminGroupFixture(1);
                      $scope->createAdminUserFixture();
          Severity: Major
          Found in tests/src/menu/ItemSqliteTest.php and 1 other location - About 1 hr to fix
          tests/src/menu/QuerySqliteTest.php on lines 89..100

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

          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

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

              public function testColumn()
              {
                  PageScope::run($this->app, function (PageScope $scope) {
                      $scope->createAdminGroupFixture(1);
                      $scope->createAdminUserFixture();
          Severity: Major
          Found in tests/src/menu/QuerySqliteTest.php and 1 other location - About 1 hr to fix
          tests/src/menu/ItemSqliteTest.php on lines 38..49

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

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

              public function actionIndex($itemId, $version = false, $date = false): \yii\web\Response|string
              {
                  if (Yii::$app->adminuser->isGuest) {
                      throw new ForbiddenHttpException('Unable to see the preview page, session expired or not logged in.');
                  }
          Severity: Minor
          Found in src/frontend/controllers/PreviewController.php - About 1 hr to fix

            Method testMatchRequestPath has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function testMatchRequestPath()
                {
                    $fixture = new NgRestModelFixture([
                        'modelClass' => Redirect::class
                    ]);
            Severity: Minor
            Found in tests/src/models/RedirectTest.php - About 1 hr to fix

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

                      $scope.removeFromFav = function(item) {
                          $http.post('admin/api-cms-block/remove-fav', {block: item }).then(function(response) {
                              $scope.blocksDataReload();
                          });
                      };
              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 1787..1791

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

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

                  private function buildList(QueryIteratorFilter $iterator, $i = 1)
                  {
                      // Abort if maxDepth is set & reached
                      if ($this->maxDepth !== null && $i >= ($this->maxDepth + 1)) {
                          return "";
              Severity: Minor
              Found in src/widgets/NavTree.php - About 1 hr to fix

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

                        $scope.addToFav = function(item) {
                            $http.post('admin/api-cms-block/to-fav', {block: item }).then(function(response) {
                                $scope.blocksDataReload();
                            });
                        };
                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 1793..1797

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

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

                    public function actionDelete($navId)
                    {
                        if (!Yii::$app->adminuser->canRoute(Module::ROUTE_PAGE_DELETE)) {
                            throw new ForbiddenHttpException("Unable to remove this page due to permission restrictions.");
                        }
                Severity: Minor
                Found in src/admin/apis/NavController.php - About 1 hr to fix

                  Function dropItemPlaceholder has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          $scope.dropItemPlaceholder = function(dragged,dropped,position) {
                              if (dragged.hasOwnProperty('favorized') || dragged.hasOwnProperty('newblock')) {
                                  // its a new block
                                  $http.post('admin/api-cms-navitempageblockitem/create', {
                                      prev_id : dropped.prev_id,
                  Severity: Minor
                  Found in src/admin/resources/js/cmsadmin.js - About 1 hr to fix

                    Function dropItemPlaceholder has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            $scope.dropItemPlaceholder = function(dragged,dropped,position) {
                                if (dragged.hasOwnProperty('favorized') || dragged.hasOwnProperty('newblock')) {
                                    // its a new block
                                    $http.post('admin/api-cms-navitempageblockitem/create', {
                                        prev_id: dropped.prev_id, 
                    Severity: Minor
                    Found in src/admin/resources/js/cmsadmin.js - About 1 hr to fix

                      Method testFindByTags has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

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

                        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

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language