luyadev/luya-module-admin

View on GitHub

Showing 503 of 503 total issues

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

            $scope.moveDown = function (index) {
                index = parseInt(index);
                var oldRow = $scope.model[index];
                $scope.model[index] = $scope.model[index + 1];
                $scope.model[index + 1] = oldRow;
Severity: Major
Found in src/resources/js/formdirectives.js and 11 other locations - About 2 hrs to fix
src/resources/js/formdirectives.js on lines 182..187
src/resources/js/formdirectives.js on lines 189..194
src/resources/js/formdirectives.js on lines 2501..2506
src/resources/js/formdirectives.js on lines 2508..2513
src/resources/js/formdirectives.js on lines 2678..2683
src/resources/js/formdirectives.js on lines 2685..2690
src/resources/js/formdirectives.js on lines 2780..2785
src/resources/js/formdirectives.js on lines 2882..2887
src/resources/js/formdirectives.js on lines 2889..2894
src/resources/js/formdirectives.js on lines 3061..3066
src/resources/js/formdirectives.js on lines 3068..3073

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

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

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

            if ($scope.model === undefined) {
                $scope.model = [{ 0: '' }];
            }
Severity: Major
Found in src/resources/js/formdirectives.js - About 2 hrs to fix

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

    class StorageController extends RestController
    {
        use CacheableTrait;
    
        /**
    Severity: Minor
    Found in src/apis/StorageController.php - About 2 hrs to fix

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

              controller: ['$scope', '$http', '$filter', 'ServiceFiltersData', 'ServiceImagesData', 'AdminToastService', 'ServiceFilesData', function ($scope, $http, $filter, ServiceFiltersData, ServiceImagesData, AdminToastService, ServiceFilesData) {
      
                  // ServiceFiltesrData inheritance
      
                  //$scope.ngModel = 0;
      Severity: Major
      Found in src/resources/js/directives.js - About 2 hrs to fix

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

            protected function updateItemIndex(AfterSaveEvent $event, $isNewRecord = false)
            {
                $attributeName = self::sortableField();
                $oldPosition = array_key_exists($attributeName, $event->changedAttributes) ? $event->changedAttributes[$attributeName] : false;
                $newPosition = $event->sender[$attributeName];
        Severity: Minor
        Found in src/traits/SortableTrait.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

        File LoginController.php has 273 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        namespace luya\admin\controllers;
        
        use luya\admin\assets\Login;
        Severity: Minor
        Found in src/controllers/LoginController.php - About 2 hrs to fix

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

                      } else if (data.status == 404) {
                          var message = data.data.hasOwnProperty('message');
                          if (message) {
                              AdminToastService.info(data.data.message, 10000);
                          } else {
          Severity: Major
          Found in src/resources/js/zaa.js and 1 other location - About 2 hrs to fix
          src/resources/js/zaa.js on lines 367..375

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

          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

                      } else if (data.status != 422) {
                          var message = data.data.hasOwnProperty('message');
                          if (message) {
                              AdminToastService.error(data.data.message, 10000);
                          } else {
          Severity: Major
          Found in src/resources/js/zaa.js and 1 other location - About 2 hrs to fix
          src/resources/js/zaa.js on lines 360..375

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

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

              public function actionDashboard($nodeId)
              {
                  $data = Yii::$app->adminmenu->getNodeData($nodeId);
                  $accessList = [];
          
          
          Severity: Major
          Found in src/apis/MenuController.php - About 2 hrs to fix

            File scheduler.js has 268 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

             /**
              * LUYA admin scheduler directive.
              * 
              * The scheduler directive will turn any field into an interactive scheduling system.
              * 
            Severity: Minor
            Found in src/resources/js/scheduler.js - About 2 hrs to fix

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

                  public function generateModelContent($fileNamepsace, $className, $apiEndpoint, TableSchema $schema, $i18nFields)
                  {
                      $alias = Inflector::humanize(Inflector::camel2words($className));
                      $dbTableName = $schema->fullName;
              
              
              Severity: Minor
              Found in src/commands/CrudController.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 actionDashboard has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function actionDashboard($nodeId)
                  {
                      $data = Yii::$app->adminmenu->getNodeData($nodeId);
                      $accessList = [];
              
              
              Severity: Minor
              Found in src/apis/MenuController.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 startFiles has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function startFiles()
                  {
                      $fileCount = 0;
                      // sync files
                      foreach ((new Query())->where(['is_deleted' => false])->all() as $file) {
              Severity: Minor
              Found in src/proxy/ClientTransfer.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

              File Plugin.php has 267 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              namespace luya\admin\ngrest\base;
              
              use luya\admin\base\TypesInterface;
              Severity: Minor
              Found in src/ngrest/base/Plugin.php - About 2 hrs to fix

                Method actionSync has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function actionSync()
                    {
                        $this->db = Instance::ensure($this->db, Connection::class);
                
                        if ($this->url === null) {
                Severity: Major
                Found in src/commands/ProxyController.php - About 2 hrs to fix

                  StorageFile has 22 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  final class StorageFile extends ActiveRecord
                  {
                      use TaggableTrait;
                  
                      /**
                  Severity: Minor
                  Found in src/models/StorageFile.php - About 2 hrs to fix

                    StorageImage has 22 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class StorageImage extends NgRestModel
                    {
                        /**
                         * @inheritdoc
                         */
                    Severity: Minor
                    Found in src/models/StorageImage.php - About 2 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

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

                                controller: ['$scope', '$filter', function ($scope, $filter) {
                        
                                    $scope.searchString;
                        
                                    $scope.sourceData = [];
                        Severity: Major
                        Found in src/resources/js/formdirectives.js - About 2 hrs to fix

                          File Module.php has 261 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          <?php
                          
                          namespace luya\admin;
                          
                          use luya\admin\base\ReloadButton;
                          Severity: Minor
                          Found in src/Module.php - About 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language