luyadev/luya-module-cms

View on GitHub

Showing 326 of 326 total issues

Function actionDataBlocks has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function actionDataBlocks()
    {
        $favs = Yii::$app->adminuser->identity->setting->get("blockfav", []);
        $groups = [];
        foreach (BlockGroup::find()->with(['blocks'])->all() as $blockGroup) {
Severity: Minor
Found in src/admin/apis/AdminController.php - About 2 hrs 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 importLayoutFile has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function importLayoutFile($file, $aliased, $themeName = null)
    {
        if (!file_exists($file)) {
            return false;
        }
Severity: Major
Found in src/admin/importers/CmslayoutImporter.php - About 2 hrs to fix

    ConcretImplementationBlock has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ConcretImplementationBlock implements BlockInterface
    {
        public function onRegister()
        {
        }
    Severity: Minor
    Found in tests/data/blocks/ConcretImplementationBlock.php - About 2 hrs to fix

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

                  angular.forEach($scope.block.vars, function(varItem) {
                      if (varItem.required && $scope.isEmpty($scope.data, varItem.var)) {
                          AdminToastService.error(i18nParam('js_block_attribute_empty', {label: varItem.label}));
                          response = true;
                      }
      Severity: Major
      Found in src/admin/resources/js/cmsadmin.js and 1 other location - About 2 hrs to fix
      src/admin/resources/js/cmsadmin.js on lines 1727..1733

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

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

          public function testTeardownWithHidden()
          {
              $this->createAdminGroupFixture(1);
              $this->createAdminUserFixture();
              $this->createAdminLangFixture([
      Severity: Major
      Found in tests/src/menu/ItemSqliteTest.php - About 2 hrs to fix

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

                    angular.forEach($scope.block.cfgs, function(varItem) {
        
                        if (varItem.required && $scope.isEmpty($scope.cfgdata, varItem.var)) {
                            AdminToastService.error(i18nParam('js_block_attribute_empty', {label: varItem.label}));
                            response = true;
        Severity: Major
        Found in src/admin/resources/js/cmsadmin.js and 1 other location - About 2 hrs to fix
        src/admin/resources/js/cmsadmin.js on lines 1720..1725

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

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

            public function testGetProperties()
            {
                PermissionScope::run($this->app, function (PermissionScope $scope) {
                    $this->createAdminLangFixture();
                    $this->createCmsNavItemRedirectFixture();
        Severity: Major
        Found in tests/src/admin/apis/NavControllerTest.php - About 2 hrs to fix

          Method testDescendentsMultiple has 68 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function testDescendentsMultiple()
              {
                  $this->createAdminGroupFixture(1);
                  $this->createAdminUserFixture();
          
          
          Severity: Major
          Found in tests/src/menu/ItemSqliteTest.php - About 2 hrs to fix

            Method createPageFromDraft has 67 lines of code (exceeds 25 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: Major
            Found in src/models/Nav.php - About 2 hrs to fix

              Method actionGeneric has 67 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function actionGeneric()
                  {
                      if (Config::has(self::MIGRATION_CODE_100)) {
                          return $this->outputError("Command already executed. System is up-to-date.");
                      }
              Severity: Major
              Found in src/frontend/commands/UpdaterController.php - About 2 hrs to fix

                NavController has 24 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class NavController extends \luya\admin\base\RestController
                {
                    private function postArg($name, $defautValue = null)
                    {
                        return Yii::$app->request->post($name, $defautValue);
                Severity: Minor
                Found in src/admin/apis/NavController.php - About 2 hrs to fix

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

                              controller : ['$scope', '$http', '$filter', 'ServiceMenuData', 'ServiceLanguagesData', 'AdminToastService', 'ServiceCurrentWebsite', function($scope, $http, $filter, ServiceMenuData, ServiceLanguagesData, AdminToastService, ServiceCurrentWebsite) {
                  
                                  $scope.error = [];
                                  $scope.success = false;
                  
                  
                  Severity: Major
                  Found in src/admin/resources/js/cmsadmin.js - About 2 hrs to fix

                    Function actionGeneric has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function actionGeneric()
                        {
                            if (Config::has(self::MIGRATION_CODE_100)) {
                                return $this->outputError("Command already executed. System is up-to-date.");
                            }
                    Severity: Minor
                    Found in src/frontend/commands/UpdaterController.php - About 2 hrs 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 registerToAppView has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static function registerToAppView(array $blockAssets, array $assetBundles)
                        {
                            $appView = Yii::$app->view;
                    
                            foreach ($blockAssets as $attribute => $blockAsset) {
                    Severity: Minor
                    Found in src/base/PhpBlockView.php - About 2 hrs 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

                    NavItemPage has 23 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class NavItemPage extends NavItemType implements NavItemTypeInterface, ViewContextInterface
                    {
                        use CacheableTrait;
                    
                        /**
                    Severity: Minor
                    Found in src/models/NavItemPage.php - About 2 hrs to fix

                      Function comparePlaceholders has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function comparePlaceholders($array1, $array2)
                          {
                              if (!array_key_exists('placeholders', $array1) || !array_key_exists('placeholders', $array2)) {
                                  return false;
                              }
                      Severity: Minor
                      Found in src/admin/importers/CmslayoutImporter.php - About 2 hrs 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 actionDataBlocks has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function actionDataBlocks()
                          {
                              $favs = Yii::$app->adminuser->identity->setting->get("blockfav", []);
                              $groups = [];
                              foreach (BlockGroup::find()->with(['blocks'])->all() as $blockGroup) {
                      Severity: Major
                      Found in src/admin/apis/AdminController.php - About 2 hrs to fix

                        Method getBlockItem has 59 lines of code (exceeds 25 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: Major
                        Found in src/models/NavItemPage.php - About 2 hrs to fix

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

                                      128 =>
                                      [
                                              'id' => '128',
                                              'nav_id' => '89',
                                              'lang' => 'fr',
                          Severity: Major
                          Found in tests/src/menu/_dataFrArray.php and 1 other location - About 2 hrs to fix
                          tests/src/menu/_dataFrArray.php on lines 735..759

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

                          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

                                      136 =>
                                      [
                                              'id' => '136',
                                              'nav_id' => '60',
                                              'lang' => 'fr',
                          Severity: Major
                          Found in tests/src/menu/_dataFrArray.php and 1 other location - About 2 hrs to fix
                          tests/src/menu/_dataFrArray.php on lines 478..502

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

                          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