pulsarvp/vps-tools

View on GitHub

Showing 201 of 201 total issues

File UserController.php has 302 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

    namespace vps\tools\modules\user\controllers;

    use app\base\Controller;
Severity: Minor
Found in src/modules/user/controllers/UserController.php - About 3 hrs to fix

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

                if ($r->isPost and $object->load($post))
                {
                    if ($object->validate())
                    {
                        if ($object->save())
    Severity: Major
    Found in src/modules/export/controllers/ExportController.php and 1 other location - About 3 hrs to fix
    src/modules/export/controllers/ExportController.php on lines 43..56

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

    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

                if ($r->isPost and $model->load($post))
                {
                    if ($model->validate())
                    {
                        if ($model->save())
    Severity: Major
    Found in src/modules/export/controllers/ExportController.php and 1 other location - About 3 hrs to fix
    src/modules/export/controllers/ExportController.php on lines 98..111

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

    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

            public function moveUp ()
            {
                if ($this->hasAttribute('order'))
                {
                    $query = self::find()->where([ '>', 'order', $this->order ])->orderBy('order ASC');
    Severity: Major
    Found in src/base/BaseOrderModel.php and 1 other location - About 3 hrs to fix
    src/base/BaseOrderModel.php on lines 114..136

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

    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

            public function moveDown ()
            {
                if ($this->hasAttribute('order'))
                {
                    $query = self::find()->where([ '<', 'order', $this->order ])->orderBy('order DESC');
    Severity: Major
    Found in src/base/BaseOrderModel.php and 1 other location - About 3 hrs to fix
    src/base/BaseOrderModel.php on lines 84..106

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

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

            private function savePage ($model)
            {
                $r = Yii::$app->request;
                if ($r->isPost and $model->load($r->post()))
                {
    Severity: Minor
    Found in src/modules/page/controllers/PageController.php - About 3 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 run has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            public function run ()
            {
                $userClass = Yii::$app->getModule('users')->modelUser;
    
                $query = $userClass::find()->select("user.*,(SELECT GROUP_CONCAT(item_name) from `auth_assignment` where `user`.`id`=`auth_assignment`.`user_id`) as rolesNames")->leftJoin('auth_assignment', '`auth_assignment`.`user_id` = `user`.`id`');
    Severity: Major
    Found in src/modules/user/widgets/RbacWidget.php - About 2 hrs to fix

      File FileHelper.php has 281 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
          namespace vps\tools\helpers;
      
          use yii\base\UnknownMethodException;
      Severity: Minor
      Found in src/helpers/FileHelper.php - About 2 hrs to fix

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

                public function up ()
                {
                    $this->createTable('auth_rule', [
                        'name'       => $this->string(64)->notNull(),
                        'data'       => $this->text()->null(),
        Severity: Major
        Found in src/modules/user/migrations/m010203_400005_init_rbac.php - About 2 hrs to fix

          Method actionGenerateXls has 66 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  public function actionGenerateXls ($id)
                  {
                      $export = Export::find()->where([ 'id' => $id ])->one();
                      if ($export === null)
                      {
          Severity: Major
          Found in src/modules/export/controllers/ExportController.php - About 2 hrs to fix

            Method actionView has 64 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    public function actionView ($id)
                    {
                        $this->_tpl = '@userViews/index';
                        $userClass = $this->module->modelUser;
                        $user = $userClass::findOne($id);
            Severity: Major
            Found in src/modules/user/controllers/UserController.php - About 2 hrs to fix

              Method sendMessage has 64 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      public function sendMessage ($data)
                      {
                          if (Yii::$app->settings->get('kafka_use'))
                          {
              
              
              Severity: Major
              Found in src/components/Kafka.php - About 2 hrs to fix

                Method bootstrap has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        public function bootstrap ($app)
                        {
                            $app->setAliases([ '@userViews' => __DIR__ . '/views/user' ]);
                            $app->setAliases([ '@rbacViews' => __DIR__ . '/views/rbac' ]);
                            $app->getUrlManager()->addRules([
                Severity: Major
                Found in src/modules/user/Module.php - About 2 hrs to fix

                  Method successAuth has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          public function successAuth ($client)
                          {
                              if (method_exists($client, 'successAuth'))
                              {
                                  $user = $client->successAuth();
                  Severity: Major
                  Found in src/modules/user/controllers/UserController.php - About 2 hrs to fix

                    Method add has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            private static function add ($message, $type, $isRaw, $category = 'admin')
                            {
                                if (Yii::$app->settings->get('log_use'))
                                {
                                    if (Yii::$app->settings->get('log_clean_mb4_chars')) {
                    Severity: Major
                    Found in src/modules/log/components/LogManager.php - About 2 hrs to fix

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

                              public function hasPermission ($permission = null, $and = false)
                              {
                                  if (Yii::$app->user->can(User::R_ADMIN))
                                      return true;
                      
                      
                      Severity: Minor
                      Found in src/modules/user/models/User.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

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

                      <?php
                          /**
                           * @author    Evgenii Kuteiko <kuteiko@mail.ru>
                           * @copyright Copyright (c) 2018
                           * @date      2018-07-12
                      Severity: Major
                      Found in src/widgets/CssWidget.php and 1 other location - About 2 hrs to fix
                      src/widgets/JsWidget.php on lines 1..47

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

                      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

                                  if ($type == 'checkbox')
                                      return self::checkboxList($name, $selected, $items, [ 'class' => 'btn-group', 'data-toggle' => 'buttons', 'item' => function ($index, $label, $name, $checked, $value)
                                      {
                                          return self::label(self::checkbox($name, $checked, [ 'autocomplete' => 'off', 'value' => $value ]) . ' ' . $label, null, [ 'class' => 'btn btn-default' . ( $checked ? ' active' : '' ) ]);
                                      } ]);
                      Severity: Major
                      Found in src/helpers/Html.php and 1 other location - About 2 hrs to fix
                      src/helpers/Html.php on lines 79..83

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

                      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
                                      return self::radioList($name, $selected, $items, [ 'class' => 'btn-group', 'data-toggle' => 'buttons', 'item' => function ($index, $label, $name, $checked, $value)
                                      {
                                          return self::label(self::radio($name, $checked, [ 'autocomplete' => 'off', 'value' => $value ]) . ' ' . $label, null, [ 'class' => 'btn btn-default' . ( $checked ? ' active' : '' ) ]);
                                      } ]);
                      Severity: Major
                      Found in src/helpers/Html.php and 1 other location - About 2 hrs to fix
                      src/helpers/Html.php on lines 74..83

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

                      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

                      <?php
                          /**
                           * @author    Evgenii Kuteiko <kuteiko@mail.ru>
                           * @copyright Copyright (c) 2018
                           * @date      2018-07-12
                      Severity: Major
                      Found in src/widgets/JsWidget.php and 1 other location - About 2 hrs to fix
                      src/widgets/CssWidget.php on lines 1..47

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

                      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