luyadev/luya-module-cms

View on GitHub

Showing 209 of 326 total issues

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

            controller : ['$scope', function($scope) {

                $scope.changeModel = function(data) {
                    $scope.navId = data.id;
                }
Severity: Major
Found in src/admin/resources/js/cmsadmin.js - About 2 hrs to fix

    Function actionCleanup has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        public function actionCleanup()
        {
            // return all pages with deleted items
            $navIds = Nav::find()->where(['is_deleted' => true])->select(['id'])->column();
    
    
    Severity: Minor
    Found in src/frontend/commands/PageController.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 getRowDescriber has a Cognitive Complexity of 16 (exceeds 5 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 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 testRenderFrontend has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function testRenderFrontend()
        {
            $this->createAdminLangFixture([
                1 => [
                    'id' => 1,
    Severity: Major
    Found in tests/src/frontend/blocks/MirrorLanguageBlockTest.php - About 2 hrs to fix

      Method loadWebsiteLanguageContainer has 48 lines of code (exceeds 25 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 1 hr to fix

        Function actionGetNavItemPath has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            public function actionGetNavItemPath($navId)
            {
                $data = "";
                $node = NavItem::find()->where(['nav_id' => $navId])->one();
                if ($node) {
        Severity: Minor
        Found in src/admin/apis/NavItemController.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 run has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            public function run()
            {
                $currentLang = Yii::$app->composition['langShortCode'];
        
                $rule = Yii::$app->menu->currentUrlRule;
        Severity: Minor
        Found in src/widgets/LangSwitcher.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 getLink has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getLink()
            {
                // take care of redirect
                if ($this->getType() === 3 && !empty($this->redirectMapData('value'))) {
                    // generate convert object to determine correctn usage.
        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 copyPageItem has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function copyPageItem(NavItem $targetNavItem)
            {
                if ($this->nav_item_type !== self::TYPE_PAGE) {
                    return false;
                }
        Severity: Minor
        Found in src/models/NavItem.php - About 1 hr to fix

          Method ngRestAttributeTypes has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function ngRestAttributeTypes()
              {
                  return [
                      'name' => 'text',
                      'host' => 'slug',
          Severity: Minor
          Found in src/models/Website.php - About 1 hr to fix

            Method actionCleanup has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function actionCleanup()
                {
                    // return all pages with deleted items
                    $navIds = Nav::find()->where(['is_deleted' => true])->select(['id'])->column();
            
            
            Severity: Minor
            Found in src/frontend/commands/PageController.php - About 1 hr to fix

              Method getItems has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function getItems()
                  {
                      if (self::$items === null) {
                          $items = Nav::find()
                              ->select(['cms_nav.id', 'nav_item_id' => 'cms_nav_item.id', 'nav_container_id', 'parent_nav_id', 'is_hidden', 'layout_file', 'is_offline', 'is_draft', 'is_home', 'cms_nav_item.title'])
              Severity: Minor
              Found in src/admin/helpers/MenuHelper.php - About 1 hr to fix

                Method testDelete has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

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

                  Function loadInheritanceData has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private static function loadInheritanceData($parentNavId = 0, $fromInheritNode = false)
                      {
                          // get items from singleton object
                          $items = self::getNavItems()[$parentNavId] ?? [];
                          foreach ($items as $item) {
                  Severity: Minor
                  Found in src/admin/helpers/MenuHelper.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 resolveCurrent has a Cognitive Complexity of 14 (exceeds 5 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

                  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 getItems has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function getItems(NavContainer $container, $parentNavId = 0, $parentGroup = [], $index = 1)
                      {
                          $navs = $container->getNavs()->andWhere(['parent_nav_id' => $parentNavId])->all();
                  
                          foreach ($navs as $nav) {
                  Severity: Minor
                  Found in src/admin/apis/MenuController.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 initializer has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          function initializer() {
                              $scope.navData = $filter('filter')($scope.menuData.items, {id: $scope.id}, true)[0];
                              if ($scope.navData == undefined) {
                                  $scope.isDraft = true;
                              } else {
                  Severity: Minor
                  Found in src/admin/resources/js/cmsadmin.js - About 1 hr to fix

                    Method createPage has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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

                      Function updateNavItemData has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              $scope.updateNavItemData = function(itemCopy, typeDataCopy) {
                                  $scope.errors = [];
                                  var headers = {"headers" : { "Content-Type" : "application/x-www-form-urlencoded; charset=UTF-8" }};
                                  var navItemId = itemCopy.id;
                      
                      
                      Severity: Minor
                      Found in src/admin/resources/js/cmsadmin.js - About 1 hr to fix

                        Method createRedirect has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function createRedirect($parentNavId, $navContainerId, $langId, $title, $alias, $redirectType, $redirectTypeValue, $description, $redirectTypeTarget, $anchor = null): array|int
                            {
                                $_errors = [];
                        
                                $nav = $this;
                        Severity: Minor
                        Found in src/models/Nav.php - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language