luyadev/luya-module-cms

View on GitHub

Showing 326 of 326 total issues

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

    public function actionMoveToChild($moveItemId, $droppedOnItemId)
    {
        $result = Nav::moveToChild($moveItemId, $droppedOnItemId);

        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 471..481

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

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

        $this->createCmsNavFixture([
            1  => [
                'id' => 1,
                'nav_container_id' => 1,
                'parent_nav_id' => 0,
Severity: Major
Found in tests/src/menu/ItemSqliteTest.php and 1 other location - About 1 hr to fix
tests/src/menu/ItemSqliteTest.php on lines 168..189

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

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

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

    public function getConfigCfgsExport()
    {
        $config = $this->config();

        if (isset($config['cfgs'])) {
Severity: Major
Found in src/base/InternalBaseBlock.php and 1 other location - About 1 hr to fix
src/base/InternalBaseBlock.php on lines 493..505

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 2 locations. Consider refactoring.
    Open

            $this->createCmsNavFixture([
                1  => [
                    'id' => 1,
                    'nav_container_id' => 1,
                    'parent_nav_id' => 0,
    Severity: Major
    Found in tests/src/menu/ItemSqliteTest.php and 1 other location - About 1 hr to fix
    tests/src/menu/ItemSqliteTest.php on lines 94..115

    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

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

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

      Method createRedirectItem has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

        Function controller has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    controller : ['$scope', 'ServiceLayoutsData', 'ServiceMenuData', function($scope, ServiceLayoutsData, ServiceMenuData) {
        
                        $scope.data.use_draft = 0;
                        $scope.data.layout_id = 0;
                        $scope.data.from_draft_id = 0;
        Severity: Minor
        Found in src/admin/resources/js/cmsadmin.js - About 1 hr to fix

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

            Method testBasicBlockImporter has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function testBasicBlockImporter()
                {
                    // config fixture
                    $configFixture = new ActiveRecordFixture([
                        'modelClass' => Config::class
            Severity: Minor
            Found in tests/src/admin/importers/BlockImporterTest.php - About 1 hr to fix

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

                  public function actionDataPermissionDelete()
                  {
                      $navId = (int) Yii::$app->request->getBodyParam('navId');
                      $groupId = (int) Yii::$app->request->getBodyParam('groupId');
              
              
              Severity: Major
              Found in src/admin/apis/MenuController.php and 1 other location - About 1 hr to fix
              src/admin/apis/MenuController.php on lines 186..196

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

              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 actionDataPermissionInsert()
                  {
                      $navId = (int) Yii::$app->request->getBodyParam('navId');
                      $groupId = (int) Yii::$app->request->getBodyParam('groupId');
              
              
              Severity: Major
              Found in src/admin/apis/MenuController.php and 1 other location - About 1 hr to fix
              src/admin/apis/MenuController.php on lines 226..236

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

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

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

                Method createPage has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

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

                  Method createPageFromDraft has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public function createPageFromDraft($parentNavId, $navContainerId, $langId, $title, $alias, $description, $fromDraftNavId, $isDraft = false): bool|array
                  Severity: Major
                  Found in src/models/Nav.php - About 1 hr to fix

                    Function loadWebsiteLanguageContainer has a Cognitive Complexity of 9 (exceeds 5 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 55 mins 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 handleLayoutFile has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function handleLayoutFile(&$layoutFiles, $path, $themeName = null)
                        {
                            $aliased = Yii::getAlias($path, false);
                            $filePath = $aliased ?: $path;
                    
                    
                    Severity: Minor
                    Found in src/admin/importers/CmslayoutImporter.php - About 55 mins 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

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

                            $scope.isEditable = function() {
                                return typeof $scope.block.vars != "undefined" && $scope.block.vars.length > 0;
                            };
                    Severity: Minor
                    Found in src/admin/resources/js/cmsadmin.js and 1 other location - About 55 mins to fix
                    src/admin/resources/js/cmsadmin.js on lines 1622..1624

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

                    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