luyadev/luya-module-cms

View on GitHub

Showing 326 of 326 total issues

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

        $scope.isConfigurable = function() {
            return typeof $scope.block.cfgs != "undefined" && $scope.block.cfgs.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 1618..1620

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

Function controller has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

            controller : ['$scope', '$http', '$filter', 'ServiceMenuData', 'ServiceLanguagesData', 'AdminToastService', 'ServiceCurrentWebsite', function($scope, $http, $filter, ServiceMenuData, ServiceLanguagesData, AdminToastService, ServiceCurrentWebsite) {
Severity: Major
Found in src/admin/resources/js/cmsadmin.js - About 50 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if ($parentNavId) {
                                $data = $node->title . '/' . $data;
                            }
    Severity: Major
    Found in src/admin/apis/NavItemController.php - About 45 mins to fix

      Function pathMatcher has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          private function pathMatcher($input, $catchPath): bool|string
          {
              // ensure request path is prefix with slash
              $requestPath = '/'.ltrim($input, '/');
      
      
      Severity: Minor
      Found in src/models/Redirect.php - About 45 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 actionCatch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function actionCatch($path)
          {
              $compositePath = Yii::$app->composition->prependTo($path);
              foreach (Redirect::find()->all() as $redirect) {
                  if ($redirect->matchRequestPath($path)) {
      Severity: Minor
      Found in src/admin/apis/RedirectController.php - About 45 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 getBlockItem has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function getBlockItem(NavItemPageBlockItem $blockItem, NavItemPage $navItemPage, array $envOptions = [])
          {
              // if the block relation could be found, return false.
              if (!$blockItem->block) {
                  return false;
      Severity: Minor
      Found in src/models/NavItemPage.php - About 45 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 actionIndex has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function actionIndex()
          {
              try {
                  $current = Yii::$app->menu->current;
              } catch (Exception $e) {
      Severity: Minor
      Found in src/frontend/controllers/DefaultController.php - About 45 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 handleBlockDefintionInDirectories has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function handleBlockDefintionInDirectories(array $directories, $blockDefinition)
          {
              $results = [];
              foreach ($directories as $directoryPath) {
                  $path = rtrim((string) $directoryPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim((string) $blockDefinition, DIRECTORY_SEPARATOR);
      Severity: Minor
      Found in src/admin/importers/BlockImporter.php - About 45 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 actionDeepPageCopy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function actionDeepPageCopy()
          {
              $navId = (int) Yii::$app->request->getBodyParam('navId');
      
              if (empty($navId)) {
      Severity: Minor
      Found in src/admin/apis/NavController.php - About 45 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

      Method createPageItem has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function createPageItem($navId, $langId, $title, $alias, $layoutId, $description): array|int
      Severity: Minor
      Found in src/models/Nav.php - About 45 mins to fix

        Function actionCreatePageVersion has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function actionCreatePageVersion()
            {
                $fromPageModel = null;
                $name = Yii::$app->request->post('name');
                $fromPageId = (int) Yii::$app->request->post('fromPageId');
        Severity: Minor
        Found in src/admin/apis/NavItemController.php - About 45 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 findInternalRedirect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function findInternalRedirect()
            {
                $path = Yii::$app->request->pathInfo;
                $compositePath = Yii::$app->composition->prependTo($path);
                foreach (Redirect::find()->all() as $redirect) {
        Severity: Minor
        Found in src/frontend/controllers/DefaultController.php - About 45 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 where has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function where(array $args)
            {
                if (ArrayHelper::isAssociative($args, false)) {
                    // ensure: ['container' => 'default', 'parent_nav_id' => 0] is possible
                    foreach ($args as $key => $value) {
        Severity: Minor
        Found in src/menu/Query.php - About 45 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 generateHtml has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            private function generateHtml($href, $isActive, $lang)
            {
                if (!array_key_exists($href, static::$registerLinkTags)) {
                    $this->view->registerLinkTag(['rel' => 'alternate', 'hreflang' => $lang['short_code'], 'href' => $href]);
                    static::$registerLinkTags[$href] = true;
        Severity: Minor
        Found in src/widgets/LangSwitcher.php - About 45 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

                foreach ($block->getConfigCfgsExport() as $var) {
                    $this->assertArrayHasKey('id', $var);
                    $this->assertArrayHasKey('var', $var);
                    $this->assertArrayHasKey('label', $var);
                    $this->assertArrayHasKey('type', $var);
        Severity: Minor
        Found in tests/src/base/BlockTest.php and 1 other location - About 40 mins to fix
        tests/src/base/BlockTest.php on lines 46..54

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

        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

                foreach ($block->getConfigVarsExport() as $var) {
                    $this->assertArrayHasKey('id', $var);
                    $this->assertArrayHasKey('var', $var);
                    $this->assertArrayHasKey('label', $var);
                    $this->assertArrayHasKey('type', $var);
        Severity: Minor
        Found in tests/src/base/BlockTest.php and 1 other location - About 40 mins to fix
        tests/src/base/BlockTest.php on lines 56..64

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

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

                $scope.renderTemplate = function(template, dataVars, cfgVars, block, extras) {
        Severity: Minor
        Found in src/admin/resources/js/cmsadmin.js - About 35 mins to fix

          Method add has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public static function add($type, array $message, $tableName, $rowId = 0, array $additionalData = [])
          Severity: Minor
          Found in src/models/Log.php - About 35 mins to fix

            Method createObject has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public static function createObject($class, $blockId, $id, $context, NavItemPage $pageObject = null): false|\luya\cms\base\BlockInterface
            Severity: Minor
            Found in src/models/Block.php - About 35 mins to fix

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

                              $scope.aliasSuggestion = function() {
                                  $scope.data.alias = $filter('slugify')($scope.data.title);
                              };
              Severity: Minor
              Found in src/admin/resources/js/cmsadmin.js and 1 other location - About 35 mins to fix
              src/admin/resources/js/cmsadmin.js on lines 594..597

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

              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