pulsarvp/vps-tools

View on GitHub

Showing 201 of 201 total issues

Method safeUp has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function safeUp ()
        {
            $this->batchInsert('setting', [ 'name', 'value', 'group', 'type', 'description' ], [
                [
                    'redis_hostname',
Severity: Minor
Found in src/migrations/redis/m181105_145549_redis_settings.php - About 1 hr to fix

    Method actionGenerate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Method sortable has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              public function sortable ($left, $right, $options = [])
              {
                  $options = array_merge($this->inputOptions, $options);
                  $this->adjustLabelFor($options);
                  $options[ 'value' ] = '';
      Severity: Minor
      Found in src/html/Field.php - About 1 hr to fix

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

                public function bootstrap ($app)
                {
                    $app->setAliases([ '@exportViews' => __DIR__ . '/views' ]);
                    $app->setAliases([ '@vpsViews' => __DIR__ . '/../../views' ]);
                    $app->getUrlManager()->addRules([
        Severity: Minor
        Found in src/modules/export/Module.php - About 1 hr to fix

          Method submitBlock has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  public function submitBlock ($submitOptions = [], $cancelOptions = null)
                  {
                      $submitOptions = array_merge([
                          'type'  => 'submit',
                          'title' => Yii::tr('Save'),
          Severity: Minor
          Found in src/html/Form.php - About 1 hr to fix

            Function read has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    public function read ()
                    {
                        try
                        {
                            $ch = curl_init();
            Severity: Minor
            Found in src/components/KafkaRest.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 init has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    public function init ()
                    {
                        $access = ( !is_null(Yii::$app->getModule('users')) and Yii::$app->getModule('users')->useAccessControl );
                        $rules = [
                            [
            Severity: Minor
            Found in src/modules/user/filters/AccessControl.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 checkAccessEnv has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    private function checkAccessEnv ()
                    {
                        $ip = Yii::$app->getRequest()->getUserIP();
                        if (isset(Yii::$app->getModule('debug')->allowedIPsDb))
                            $allowedIPsDb = Yii::$app->getModule('debug')->allowedIPsDb;
            Severity: Minor
            Found in src/controllers/WebController.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 actionGenerateXls has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    public function actionGenerateXls ($id)
                    {
                        $export = Export::find()->where([ 'id' => $id ])->one();
                        if ($export === null)
                        {
            Severity: Minor
            Found in src/modules/export/controllers/ExportController.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 beforeSave has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    public function beforeSave ($insert)
                    {
                        if ($parent = parent::beforeSave($insert))
                        {
                            if ($this->isNewRecord)
            Severity: Minor
            Found in src/modules/export/models/Export.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 beforeSave has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    public function beforeSave ($insert)
                    {
                        if ($parent = parent::beforeSave($insert))
                        {
                            if ($this->isNewRecord)
            Severity: Minor
            Found in src/base/BaseOrderModel.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 cropSquare has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    public static function cropSquare ($file, $filepath, $cropBoxData = null)
                    {
            
                        if (!RemoteFileHelper::exists($file))
                            return false;
            Severity: Minor
            Found in src/helpers/ImageHelper.php - About 1 hr to fix

              Method behaviors has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      public function behaviors ()
                      {
                          return [
                              'access' => [
                                  'class' => AccessControl::className(),
              Severity: Minor
              Found in src/modules/page/controllers/PageController.php - About 1 hr to fix

                Method behaviors has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        public function behaviors ()
                        {
                            return [
                                'access' => [
                                    'class' => AccessControl::className(),
                Severity: Minor
                Found in src/modules/menu/controllers/MenuController.php - About 1 hr to fix

                  Method printColor has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          public static function printColor ($string, $color = 'white')
                          {
                              $code = 'w';
                              switch ($color)
                              {
                  Severity: Minor
                  Found in src/helpers/Console.php - About 1 hr to fix

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

                            public function bootstrap ($app)
                            {
                                $app->setAliases([ '@logViews' => __DIR__ . '/views' ]);
                                $app->setAliases([ '@vpsViews' => __DIR__ . '/../../views' ]);
                                $app->getUrlManager()->addRules([
                    Severity: Minor
                    Found in src/modules/log/Module.php - About 1 hr to fix

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

                              protected function initUserAttributes ()
                              {
                                  $token = $this->getAccessToken();
                                  if (!is_object($token))
                                  {
                      Severity: Major
                      Found in src/auth/SSOClient.php and 1 other location - About 1 hr to fix
                      src/auth/PulsarSsoClient.php on lines 114..126

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

                      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

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

                              protected function initUserAttributes ()
                              {
                                  $token = $this->getAccessToken();
                                  if (!is_object($token))
                                  {
                      Severity: Major
                      Found in src/auth/PulsarSsoClient.php and 1 other location - About 1 hr to fix
                      src/auth/SSOClient.php on lines 91..103

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

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

                              public static function compress ($input, $preserve = [ 'textarea', 'pre' ])
                              {
                                  $output = trim($input);
                      
                                  // First, store tags which should not been minified.
                      Severity: Minor
                      Found in src/helpers/Html.php - About 1 hr to fix

                        Method saveImage has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                public function saveImage ($path, $file, $resize = false)
                                {
                                    $filename = UuidHelper::generate() . '.' . $file->extension;
                                    $name = $filename[ 0 ] . DIRECTORY_SEPARATOR . $filename[ 1 ] . DIRECTORY_SEPARATOR . $filename;
                                    $filepath = $path . DIRECTORY_SEPARATOR . $name;
                        Severity: Minor
                        Found in src/components/ImageManager.php - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language