pulsarvp/vps-tools

View on GitHub

Showing 201 of 201 total issues

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

        public static function toBytes ($string)
        {
            $value = null;
            $string = strtoupper($string);

Severity: Minor
Found in src/helpers/HumanHelper.php - About 1 hr to fix

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

            private function saveRole ($roleForm)
            {
    
                $auth = Yii::$app->getAuthManager();
                $role = $auth->createRole($roleForm->name);
    Severity: Minor
    Found in src/modules/user/widgets/RbacWidget.php - About 1 hr to fix

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

      <?php
      
          namespace vps\tools\dictionaries;
      
          /**
      Severity: Major
      Found in src/dictionaries/Base.php and 1 other location - About 1 hr to fix
      src/base/BaseDictionary.php on lines 1..27

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

      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
      
          namespace vps\tools\base;
      
          /**
      Severity: Major
      Found in src/base/BaseDictionary.php and 1 other location - About 1 hr to fix
      src/dictionaries/Base.php on lines 1..27

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

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

              public function tags ($options = [])
              {
                  $options[ 'data-role' ] = 'tagsinput';
      
                  $this->adjustLabelFor($options);
      Severity: Minor
      Found in src/html/Field.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 mix has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              public static function mix ($array, $num)
              {
                  if (is_array($array))
                  {
                      $data = [];
      Severity: Minor
      Found in src/helpers/ArrayHelper.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 save has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              public function save ()
              {
                  $auth = Yii::$app->getAuthManager();
                  $role = $auth->createRole($this->name);
                  $role->type = Role::TYPE_ROLE;
      Severity: Minor
      Found in src/modules/user/forms/RoleForm.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 saveRole has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              private function saveRole ($roleForm)
              {
      
                  $auth = Yii::$app->getAuthManager();
                  $role = $auth->createRole($roleForm->name);
      Severity: Minor
      Found in src/modules/user/widgets/RbacWidget.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 emptyToNull has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              public static function emptyToNull ($array)
              {
                  if (is_array($array))
                  {
                      $return = [];
      Severity: Minor
      Found in src/helpers/ArrayHelper.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 actionSendElk has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              public function actionSendElk ()
              {
                  $logs = Log::find()->orderBy([ 'dt' => SORT_ASC ])->all();
                  if (Yii::$app->settings->get('log_ssl_use'))
                  {
      Severity: Minor
      Found in src/modules/log/controllers/LogConsoleController.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 actionEdit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              public function actionEdit ($id)
              {
                  $r = Yii::$app->request;
                  $post = $r->post();
      
      
      Severity: Minor
      Found in src/modules/export/controllers/ExportController.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 actionAdd has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              public function actionAdd ()
              {
      
                  $menu = new Menu();
                  $this->_tpl = '@menuViews/add';
      Severity: Minor
      Found in src/modules/menu/controllers/MenuController.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 mergeColumns has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              public static function mergeColumns ()
              {
                  $count = [];
                  $args = func_get_args();
      
      
      Severity: Minor
      Found in src/helpers/ArrayHelper.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 bitrate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              public static function bitrate ($bitrate, $unit = '')
              {
                  if (is_numeric($bitrate) and $bitrate >= 0)
                  {
                      if (( !$unit && $bitrate >= 1000000 ) || $unit == 'mb/s')
      Severity: Minor
      Found in src/helpers/HumanHelper.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 delete has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              public static function delete (&$array, $key)
              {
                  $value = null;
      
                  if (is_array($array) and ( is_string($key) or is_numeric($key) ))
      Severity: Minor
      Found in src/helpers/ArrayHelper.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

      Avoid deeply nested control flow statements.
      Open

                                      if (isset($config[ $name ]))
                                          Console::printColor('   ' . $name . ' = ' . $config[ $name ], 'green');
      Severity: Major
      Found in src/controllers/ConfigController.php - About 45 mins to fix

        Function addApp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                private function addApp ()
                {
                    $appNew = new Apiapp();
                    if (Yii::$app->request->post('method') == 'apiapp')
                    {
        Severity: Minor
        Found in src/modules/apiapp/widgets/ApiappWidget.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 filterKeys has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                public static function filterKeys ($array, $keys)
                {
                    if (is_array($array))
                    {
                        $return = [];
        Severity: Minor
        Found in src/helpers/ArrayHelper.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 printColor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                public static function printColor ($string, $color = 'white')
                {
                    $code = 'w';
                    switch ($color)
                    {
        Severity: Minor
        Found in src/helpers/Console.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 saveImage has a Cognitive Complexity of 8 (exceeds 5 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 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

        Severity
        Category
        Status
        Source
        Language