plugins/redis/admin_modules/yf_manage_redis.class.php

Summary

Maintainability
F
4 days
Test Coverage

Function show has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

    public function show()
    {
        $i = preg_replace('~[^a-z0-9_-]+~ims', '', trim($_GET['i'])); // instance
        $g = preg_replace('~[^a-z0-9_-]+~ims', '', trim($_GET['g'])); // group
        $t = preg_replace('~[^a-z0-9_-]+~ims', '', trim($_GET['t'])); // type
Severity: Minor
Found in plugins/redis/admin_modules/yf_manage_redis.class.php - About 6 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 delete has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    public function delete()
    {
        $i = preg_replace('~[^a-z0-9_]+~ims', '', trim($_GET['i']));
        if ( ! $i || ! isset($this->instances[$i])) {
            return js_redirect('/@object');
Severity: Minor
Found in plugins/redis/admin_modules/yf_manage_redis.class.php - About 5 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 yf_manage_redis.class.php has 383 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

class yf_manage_redis
{
    public $types = [
Severity: Minor
Found in plugins/redis/admin_modules/yf_manage_redis.class.php - About 5 hrs to fix

    Method show has 128 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function show()
        {
            $i = preg_replace('~[^a-z0-9_-]+~ims', '', trim($_GET['i'])); // instance
            $g = preg_replace('~[^a-z0-9_-]+~ims', '', trim($_GET['g'])); // group
            $t = preg_replace('~[^a-z0-9_-]+~ims', '', trim($_GET['t'])); // type
    Severity: Major
    Found in plugins/redis/admin_modules/yf_manage_redis.class.php - About 5 hrs to fix

      Method edit has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function edit()
          {
              if (is_post() && isset($_POST['mass_delete']) && $_POST['id']) {
                  $_GET['action'] = 'delete';
                  return $this->delete();
      Severity: Major
      Found in plugins/redis/admin_modules/yf_manage_redis.class.php - About 2 hrs to fix

        Method _init has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function _init()
            {
                $i_default = redis();
                $i_cache = strpos(strtolower(cache()->DRIVER), 'redis') !== false ? cache()->_driver->_connection : null;
                if (ini_get('session.save_handler') == 'redis' && preg_match('~tcp://(?P<host>[a-z0-9_-]+):(?P<port>[0-9]+)~ims', ini_get('session.save_path'), $m)) {
        Severity: Major
        Found in plugins/redis/admin_modules/yf_manage_redis.class.php - About 2 hrs to fix

          Function _do_delete has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              public function _do_delete($r, $id, $keys_to_del = [])
              {
                  if ( ! $keys_to_del) {
                      return false;
                  }
          Severity: Minor
          Found in plugins/redis/admin_modules/yf_manage_redis.class.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

          Method delete has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function delete()
              {
                  $i = preg_replace('~[^a-z0-9_]+~ims', '', trim($_GET['i']));
                  if ( ! $i || ! isset($this->instances[$i])) {
                      return js_redirect('/@object');
          Severity: Major
          Found in plugins/redis/admin_modules/yf_manage_redis.class.php - About 2 hrs to fix

            Function edit has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public function edit()
                {
                    if (is_post() && isset($_POST['mass_delete']) && $_POST['id']) {
                        $_GET['action'] = 'delete';
                        return $this->delete();
            Severity: Minor
            Found in plugins/redis/admin_modules/yf_manage_redis.class.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 _init has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                public function _init()
                {
                    $i_default = redis();
                    $i_cache = strpos(strtolower(cache()->DRIVER), 'redis') !== false ? cache()->_driver->_connection : null;
                    if (ini_get('session.save_handler') == 'redis' && preg_match('~tcp://(?P<host>[a-z0-9_-]+):(?P<port>[0-9]+)~ims', ini_get('session.save_path'), $m)) {
            Severity: Minor
            Found in plugins/redis/admin_modules/yf_manage_redis.class.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

            Avoid too many return statements within this method.
            Open

                    return $default;
            Severity: Major
            Found in plugins/redis/admin_modules/yf_manage_redis.class.php - About 30 mins to fix

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

                      foreach ($avail_types as $type => $count) {
                          $is_selected = $t && strtolower($t) == strtolower($type);
                          $filters[] = a('/@object/?i=' . $i . '&t=' . strtolower($type), '', 'fa fa-cog', $type . '&nbsp;(' . $count . ')', $is_selected ? 'btn-warning' : 'btn-info', '');
                      }
              Severity: Minor
              Found in plugins/redis/admin_modules/yf_manage_redis.class.php and 1 other location - About 55 mins to fix
              plugins/redis/admin_modules/yf_manage_redis.class.php on lines 153..158

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

              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 ($count > 1) {
                              $is_selected = $g && strtolower($g) == strtolower($name);
                              $filters[] = a('/@object/?i=' . $i . '&g=' . urlencode($name), '', 'fa fa-filter', $name . '&nbsp;(' . $count . ')', $is_selected ? 'btn-warning' : '', '');
                          } else {
                              unset($groups[$name]);
              Severity: Minor
              Found in plugins/redis/admin_modules/yf_manage_redis.class.php and 1 other location - About 55 mins to fix
              plugins/redis/admin_modules/yf_manage_redis.class.php on lines 211..214

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

              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

              There are no issues that match your filters.

              Category
              Status