plugins/sys/classes/core_api/yf_core_api_admin_modules.class.php

Summary

Maintainability
F
1 wk
Test Coverage

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

    public function _get_modules_from_files($include_framework = true, $with_sub_modules = false)
    {
        $admin_modules_array = [];

        $pattern_include = '-f ~/' . preg_quote(ADMIN_MODULES_DIR, '~') . '.*' . preg_quote(YF_CLS_EXT, '~') . '$~';
Severity: Minor
Found in plugins/sys/classes/core_api/yf_core_api_admin_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

Function _get_methods has a Cognitive Complexity of 46 (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/sys/classes/core_api/yf_core_api_admin_modules.class.php - About 7 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 35 (exceeds 5 allowed). Consider refactoring.
Open

    public function _recursive_get_methods_from_extends($file_text = '', $user_module_name = '', $_type = 'admin', $ONLY_PRIVATE_METHODS = false)
    {
        $extends_file_path = '';
        $methods = [];
        // TODO: connect plugins
Severity: Minor
Found in plugins/sys/classes/core_api/yf_core_api_admin_modules.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

Method _get_modules_from_files has 101 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function _get_modules_from_files($include_framework = true, $with_sub_modules = false)
    {
        $admin_modules_array = [];

        $pattern_include = '-f ~/' . preg_quote(ADMIN_MODULES_DIR, '~') . '.*' . preg_quote(YF_CLS_EXT, '~') . '$~';
Severity: Major
Found in plugins/sys/classes/core_api/yf_core_api_admin_modules.class.php - About 4 hrs to fix

    Method _get_methods has 73 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/sys/classes/core_api/yf_core_api_admin_modules.class.php - About 2 hrs to fix

      File yf_core_api_admin_modules.class.php has 274 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      
      class yf_core_api_admin_modules
      {
      Severity: Minor
      Found in plugins/sys/classes/core_api/yf_core_api_admin_modules.class.php - About 2 hrs to fix

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

            public function _recursive_get_methods_from_extends($file_text = '', $user_module_name = '', $_type = 'admin', $ONLY_PRIVATE_METHODS = false)
            {
                $extends_file_path = '';
                $methods = [];
                // TODO: connect plugins
        Severity: Minor
        Found in plugins/sys/classes/core_api/yf_core_api_admin_modules.class.php - About 1 hr to fix

          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/sys/classes/core_api/yf_core_api_admin_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 = '', $_type = 'admin', $ONLY_PRIVATE_METHODS = false)
              {
                  $extends_file_path = '';
                  $methods = [];
                  // TODO: connect plugins
          plugins/admin/admin_modules/yf_admin_modules.class.php on lines 364..416

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

          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) _class('dir')->scan($dir_to_scan, true, $pattern_include) as $k => $v) {
                      $v = str_replace('//', '/', $v);
                      if (substr($v, -$yf_cls_ext_len) != YF_CLS_EXT) {
                          continue;
                      }
          plugins/sys/classes/core_api/yf_core_api_user_modules.class.php on lines 55..73

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

          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) _class('dir')->scan(PROJECT_PATH . 'plugins/', true, $pattern_include) as $k => $v) {
                      $v = str_replace('//', '/', $v);
                      if (substr($v, -$yf_cls_ext_len) != YF_CLS_EXT) {
                          continue;
                      }
          plugins/sys/classes/core_api/yf_core_api_user_modules.class.php on lines 76..94

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

          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, ($location == 'admin_with_prefix' ? YF_ADMIN_CLS_PREFIX : '') . $user_module_name, $ONLY_PRIVATE_METHODS);
                          foreach ($_methods as $method_name) {
          plugins/admin/admin_modules/yf_admin_modules.class.php on lines 327..344

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

          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->_admin_modules_array)) {
                      return $this->_admin_modules_array;
          plugins/sys/classes/core_api/yf_core_api_user_modules.class.php on lines 21..37

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

          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;
          plugins/admin/admin_modules/yf_admin_modules.class.php on lines 423..442
          plugins/sys/classes/core_api/yf_core_api_user_modules.class.php on lines 286..306
          plugins/user/admin_modules/yf_user_modules.class.php on lines 410..430

          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

          There are no issues that match your filters.

          Category
          Status