luyadev/luya-module-admin

View on GitHub
src/ngrest/base/Api.php

Summary

Maintainability
D
3 days
Test Coverage
C
74%

File Api.php has 505 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace luya\admin\ngrest\base;

use luya\admin\base\RestActiveController;
Severity: Major
Found in src/ngrest/base/Api.php - About 1 day to fix

    Api has 27 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Api extends RestActiveController
    {
        /**
         * @var string Defines the related model for the NgRest Controller. The full qualiefied model name
         * is required.
    Severity: Minor
    Found in src/ngrest/base/Api.php - About 3 hrs to fix

      Method actionExport has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function actionExport()
          {
              $extension = null;
              $mime = null;
              $header = Yii::$app->request->getBodyParam('header', 1);
      Severity: Major
      Found in src/ngrest/base/Api.php - About 2 hrs to fix

        Method actions has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function actions()
            {
                $actions = [
                    'index' => [ // for casual api request behavior
                        'class' => 'luya\admin\ngrest\base\actions\IndexAction',
        Severity: Major
        Found in src/ngrest/base/Api.php - About 2 hrs to fix

          Method actionServices has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function actionServices()
              {
                  $settings = [];
                  $apiEndpoint = $this->model->ngRestApiEndpoint();
                  $userSortSettings = Yii::$app->adminuser->identity->setting->get('ngrestorder.admin/'.$apiEndpoint, false);
          Severity: Minor
          Found in src/ngrest/base/Api.php - About 1 hr to fix

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

                public function actionExport()
                {
                    $extension = null;
                    $mime = null;
                    $header = Yii::$app->request->getBodyParam('header', 1);
            Severity: Minor
            Found in src/ngrest/base/Api.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 formatExportValues has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                private function formatExportValues(ActiveQuery $query, array $formatter)
                {
                    Yii::$app->formatter->nullDisplay = '';
                    $data = [];
                    $rowId = 0;
            Severity: Minor
            Found in src/ngrest/base/Api.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 actionRelationCall has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function actionRelationCall($arrayIndex, $id, $modelClass, $query = null)
                {
                    $modelClass = base64_decode($modelClass);
            
                    if (!class_exists($modelClass)) {
            Severity: Minor
            Found in src/ngrest/base/Api.php - About 1 hr to fix

              Function actionServices has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function actionServices()
                  {
                      $settings = [];
                      $apiEndpoint = $this->model->ngRestApiEndpoint();
                      $userSortSettings = Yii::$app->adminuser->identity->setting->get('ngrestorder.admin/'.$apiEndpoint, false);
              Severity: Minor
              Found in src/ngrest/base/Api.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 actionRelationCall has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function actionRelationCall($arrayIndex, $id, $modelClass, $query = null)
                  {
                      $modelClass = base64_decode($modelClass);
              
                      if (!class_exists($modelClass)) {
              Severity: Minor
              Found in src/ngrest/base/Api.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 getWithRelation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getWithRelation($actionName)
                  {
                      $expand = Yii::$app->request->get('expand', '');
                      $relationPrefixes = [];
                      foreach (StringHelper::explode($expand, ',', true, true) as $relation) {
              Severity: Minor
              Found in src/ngrest/base/Api.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

              Function relationsFromExpand has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function relationsFromExpand(array $relations, array $expandPrefixes)
                  {
                      $valid = [];
                      foreach ($expandPrefixes as $prefix) {
                          foreach ($relations as $relation) {
              Severity: Minor
              Found in src/ngrest/base/Api.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