plugins/user/admin_modules/yf_user_modules.class.php

Summary

Maintainability
F
1 wk
Test Coverage

Function _get_methods has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

    public function _get_methods($params = [])
    {
        $ONLY_PRIVATE_METHODS = [];
        if (isset($params['private'])) {
            $ONLY_PRIVATE_METHODS = $params['private'];
Severity: Minor
Found in plugins/user/admin_modules/yf_user_modules.class.php - About 1 day 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_user_modules.class.php has 395 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * User modules list handler.
 *
Severity: Minor
Found in plugins/user/admin_modules/yf_user_modules.class.php - About 5 hrs to fix

    Method _get_methods has 80 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function _get_methods($params = [])
        {
            $ONLY_PRIVATE_METHODS = [];
            if (isset($params['private'])) {
                $ONLY_PRIVATE_METHODS = $params['private'];
    Severity: Major
    Found in plugins/user/admin_modules/yf_user_modules.class.php - About 3 hrs to fix

      Function _get_modules_from_files has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public function _get_modules_from_files($include_framework = true, $with_sub_modules = false)
          {
              $modules = [];
      
              $yf_prefix_len = strlen(YF_PREFIX);
      Severity: Minor
      Found in plugins/user/admin_modules/yf_user_modules.class.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

      Function _recursive_get_methods_from_extends has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public function _recursive_get_methods_from_extends($file_text = '', $user_module_name = '', $ONLY_PRIVATE_METHODS = false)
          {
              // TODO: need to add 'site__' and 'adm__' functionality
              $extends_file_path = '';
              $methods = [];
      Severity: Minor
      Found in plugins/user/admin_modules/yf_user_modules.class.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 show has 75 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function show()
          {
              $this->refresh_modules_list($silent = true);
      
              if (main()->is_post()) {
      Severity: Major
      Found in plugins/user/admin_modules/yf_user_modules.class.php - About 3 hrs to fix

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

            public function show()
            {
                $this->refresh_modules_list($silent = true);
        
                if (main()->is_post()) {
        Severity: Minor
        Found in plugins/user/admin_modules/yf_user_modules.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 _get_modules_from_files has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function _get_modules_from_files($include_framework = true, $with_sub_modules = false)
            {
                $modules = [];
        
                $yf_prefix_len = strlen(YF_PREFIX);
        Severity: Minor
        Found in plugins/user/admin_modules/yf_user_modules.class.php - About 1 hr to fix

          Function refresh_modules_list has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function refresh_modules_list($silent = false)
              {
                  // Cleanup duplicate records
                  $q = db()->query('SELECT name, COUNT(*) AS num FROM ' . db('user_modules') . ' GROUP BY name HAVING num > 1');
                  while ($a = db()->fetch_assoc($q)) {
          Severity: Minor
          Found in plugins/user/admin_modules/yf_user_modules.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

          Method refresh_modules_list has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function refresh_modules_list($silent = false)
              {
                  // Cleanup duplicate records
                  $q = db()->query('SELECT name, COUNT(*) AS num FROM ' . db('user_modules') . ' GROUP BY name HAVING num > 1');
                  while ($a = db()->fetch_assoc($q)) {
          Severity: Minor
          Found in plugins/user/admin_modules/yf_user_modules.class.php - About 1 hr to fix

            Method _recursive_get_methods_from_extends has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function _recursive_get_methods_from_extends($file_text = '', $user_module_name = '', $ONLY_PRIVATE_METHODS = false)
                {
                    // TODO: need to add 'site__' and 'adm__' functionality
                    $extends_file_path = '';
                    $methods = [];
            Severity: Minor
            Found in plugins/user/admin_modules/yf_user_modules.class.php - About 1 hr to fix

              Function _get_methods_for_select has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function _get_methods_for_select($params = [])
                  {
                      $cache_name = 'user_modules_for_select';
                      $data = cache_get($cache_name);
                      if ( ! $data) {
              Severity: Minor
              Found in plugins/user/admin_modules/yf_user_modules.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

              Function _get_methods_names_from_text has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function _get_methods_names_from_text($text = '', $ONLY_PRIVATE_METHODS = false)
                  {
                      $methods = [];
                      if (empty($text)) {
                          return $methods;
              Severity: Minor
              Found in plugins/user/admin_modules/yf_user_modules.class.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

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

                  public function _recursive_get_methods_from_extends($file_text = '', $user_module_name = '', $ONLY_PRIVATE_METHODS = false)
                  {
                      // TODO: need to add 'site__' and 'adm__' functionality
                      $extends_file_path = '';
                      $methods = [];
              Severity: Major
              Found in plugins/user/admin_modules/yf_user_modules.class.php and 1 other location - About 1 day to fix
              plugins/sys/classes/core_api/yf_core_api_user_modules.class.php on lines 237..279

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

              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

                      return table($items, [
                              'condensed' => 1,
                              'pager_records_on_page' => 10000,
                              'filter' => true,
                              'filter_params' => [
              Severity: Major
              Found in plugins/user/admin_modules/yf_user_modules.class.php and 1 other location - About 7 hrs to fix
              plugins/admin/admin_modules/yf_admin_modules.class.php on lines 85..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 236.

              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

                          foreach ((array) $file_names as $location => $file_name) {
                              $file_text = file_get_contents($file_name);
                              // Try to get methods from parent classes (if exist one)
                              $_methods = $this->_recursive_get_methods_from_extends($file_text, $module_name, $ONLY_PRIVATE_METHODS);
                              foreach ($_methods as $method_name) {
              Severity: Major
              Found in plugins/user/admin_modules/yf_user_modules.class.php and 1 other location - About 6 hrs to fix
              plugins/sys/classes/core_api/yf_core_api_user_modules.class.php on lines 198..218

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

              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 _get_modules($params = [])
                  {
                      // Need to prevent multiple calls
                      if (isset($this->_user_modules_array)) {
                          return $this->_user_modules_array;
              Severity: Major
              Found in plugins/user/admin_modules/yf_user_modules.class.php and 1 other location - About 5 hrs to fix
              plugins/admin/admin_modules/yf_admin_modules.class.php on lines 177..198

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

              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 _show_filter()
                  {
                      if ( ! in_array($_GET['action'], ['show'])) {
                          return false;
                      }
              Severity: Major
              Found in plugins/user/admin_modules/yf_user_modules.class.php and 1 other location - About 4 hrs to fix
              plugins/admin/admin_modules/yf_admin_modules.class.php on lines 475..497

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

              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

                          if ($plugin_name) {
                              $places += [
                                  'framework_plugin' => ['dir' => YF_PATH . 'plugins/' . $plugin_name . '/' . $dir, 'file' => YF_PREFIX . $name . YF_CLS_EXT],
                                  'project_plugin' => ['dir' => PROJECT_PATH . 'plugins/' . $plugin_name . '/' . $dir, 'file' => $name . YF_CLS_EXT],
                                  'app_plugin' => ['dir' => APP_PATH . 'plugins/' . $plugin_name . '/' . $dir, 'file' => $name . YF_CLS_EXT],
              Severity: Major
              Found in plugins/user/admin_modules/yf_user_modules.class.php and 1 other location - About 3 hrs to fix
              plugins/admin/admin_modules/yf_admin_modules.class.php on lines 65..71

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

              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 _get_methods_for_select($params = [])
                  {
                      $cache_name = 'user_modules_for_select';
                      $data = cache_get($cache_name);
                      if ( ! $data) {
              Severity: Major
              Found in plugins/user/admin_modules/yf_user_modules.class.php and 1 other location - About 3 hrs to fix
              plugins/admin/admin_modules/yf_admin_modules.class.php on lines 448..466

              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

                          if ($plugin_name) {
                              $tmp = APP_PATH . 'plugins/' . $plugin_name . '/' . USER_MODULES_DIR . $module_name . YF_CLS_EXT;
                              if (file_exists($tmp)) {
                                  $file_names['app_plugin'] = $tmp;
                              }
              Severity: Major
              Found in plugins/user/admin_modules/yf_user_modules.class.php and 1 other location - About 2 hrs to fix
              plugins/admin/admin_modules/yf_admin_modules.class.php on lines 304..313

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

              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 4 locations. Consider refactoring.
              Open

                  public function _get_methods_names_from_text($text = '', $ONLY_PRIVATE_METHODS = false)
                  {
                      $methods = [];
                      if (empty($text)) {
                          return $methods;
              Severity: Major
              Found in plugins/user/admin_modules/yf_user_modules.class.php and 3 other locations - About 2 hrs to fix
              plugins/admin/admin_modules/yf_admin_modules.class.php on lines 423..442
              plugins/sys/classes/core_api/yf_core_api_admin_modules.class.php on lines 308..327
              plugins/sys/classes/core_api/yf_core_api_user_modules.class.php on lines 286..306

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

              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

                          $places = [
                              'framework' => ['dir' => YF_PATH . $dir, 'file' => YF_PREFIX . $name . YF_CLS_EXT],
                              'project' => ['dir' => ADMIN_SITE_PATH . $dir, 'file' => $name . YF_CLS_EXT],
                              'app' => ['dir' => APP_PATH . $dir, 'file' => $name . YF_CLS_EXT],
                          ];
              Severity: Major
              Found in plugins/user/admin_modules/yf_user_modules.class.php and 1 other location - About 1 hr to fix
              plugins/admin/admin_modules/yf_admin_modules.class.php on lines 60..64

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

              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