luyadev/luya-module-cms

View on GitHub
src/admin/apis/NavController.php

Summary

Maintainability
C
1 day
Test Coverage
F
30%

File NavController.php has 376 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace luya\cms\admin\apis;

use luya\admin\models\TagRelation;
Severity: Minor
Found in src/admin/apis/NavController.php - About 5 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 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

      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

        Method actionSaveProperties has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function actionSaveProperties($navId)
            {
                $rows = [];
        
                $doNotDeleteList = [];
        Severity: Minor
        Found in src/admin/apis/NavController.php - About 1 hr to fix

          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

          Function actionDelete has a Cognitive Complexity of 7 (exceeds 5 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 35 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 actionDeepPageCopyAsTemplate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

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

          There are no issues that match your filters.

          Category
          Status