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

Summary

Maintainability
F
1 wk
Test Coverage

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

    public function _get_modules_from_files($include_framework = true, $with_sub_modules = false)
    {
        $user_modules_array = [];
        $pattern_include = '-f ~/' . preg_quote(USER_MODULES_DIR, '~') . '.*' . preg_quote(YF_CLS_EXT, '~') . '$~';
        $pattern_no_submodules = '~/' . preg_quote(USER_MODULES_DIR, '~') . '[^/]+' . preg_quote(YF_CLS_EXT, '~') . '$~ims';
Severity: Minor
Found in plugins/sys/classes/core_api/yf_core_api_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

Function _get_methods has a Cognitive Complexity of 49 (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_user_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

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

    public function _get_modules_from_files($include_framework = true, $with_sub_modules = false)
    {
        $user_modules_array = [];
        $pattern_include = '-f ~/' . preg_quote(USER_MODULES_DIR, '~') . '.*' . preg_quote(YF_CLS_EXT, '~') . '$~';
        $pattern_no_submodules = '~/' . preg_quote(USER_MODULES_DIR, '~') . '[^/]+' . preg_quote(YF_CLS_EXT, '~') . '$~ims';
Severity: Major
Found in plugins/sys/classes/core_api/yf_core_api_user_modules.class.php - About 3 hrs to fix

    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/sys/classes/core_api/yf_core_api_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 _get_methods has 72 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_user_modules.class.php - About 2 hrs 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/sys/classes/core_api/yf_core_api_user_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_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 = [];
        plugins/user/admin_modules/yf_user_modules.class.php on lines 361..403

        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

                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_admin_modules.class.php on lines 57..75

        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_admin_modules.class.php on lines 78..96

        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, $user_module_name, $ONLY_PRIVATE_METHODS);
                        foreach ($_methods as $method_name) {
        plugins/user/admin_modules/yf_user_modules.class.php on lines 322..342

        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;
        plugins/sys/classes/core_api/yf_core_api_admin_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_admin_modules.class.php on lines 308..327
        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