plugins/sys/classes/yf_core_api.class.php

Summary

Maintainability
F
4 days
Test Coverage

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

<?php

/**
 * Core API.
 */
Severity: Major
Found in plugins/sys/classes/yf_core_api.class.php - About 1 day to fix

    yf_core_api has 59 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class yf_core_api
    {
        public $section_paths = [
            'core' => 'classes/',
            'user' => 'modules/',
    Severity: Major
    Found in plugins/sys/classes/yf_core_api.class.php - About 1 day to fix

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

          public function get_github_link($input, $section = 'all')
          {
              $is_module = false;
              $is_func = false;
              if (is_array($input)) {
      Severity: Minor
      Found in plugins/sys/classes/yf_core_api.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 get_submodules has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function get_submodules($section = 'all')
          {
              $data = [];
              foreach ($this->section_paths as $_section => $folder) {
                  if ($section != 'all' && $section != $_section) {
      Severity: Minor
      Found in plugins/sys/classes/yf_core_api.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 get_plugins has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public function get_plugins()
          {
              $folder = '';
              $suffix = '/';
              $libs = [];
      Severity: Minor
      Found in plugins/sys/classes/yf_core_api.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 get_github_link has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function get_github_link($input, $section = 'all')
          {
              $is_module = false;
              $is_func = false;
              if (is_array($input)) {
      Severity: Minor
      Found in plugins/sys/classes/yf_core_api.class.php - About 1 hr to fix

        Function get_all_hooks has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function get_all_hooks($section = 'all', $hooks_prefix = '_hook_')
            {
                $hooks_pl = strlen($hooks_prefix);
                $hooks = [];
                foreach ((array) $this->get_private_methods($section) as $module => $methods) {
        Severity: Minor
        Found in plugins/sys/classes/yf_core_api.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 show_docs has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function show_docs(array $info)
            {
                $tests = '';
                if ($info['is_func']) {
                    $tests = _class('core_api')->get_function_tests($info['name']);
        Severity: Minor
        Found in plugins/sys/classes/yf_core_api.class.php - About 1 hr to fix

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

              public function get_method_source($module, $method, $section = 'all')
              {
                  if ( ! is_object($module)) {
                      if (false !== strpos($module, '/')) {
                          list($subfolder, $module) = explode('/', $module);
          Severity: Minor
          Found in plugins/sys/classes/yf_core_api.class.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 get_libs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function get_libs($folder = 'vendor/')
              {
                  $libs = [];
                  $suffix = '/';
                  foreach ($this->get_globs($folder, $suffix) as $glob) {
          Severity: Minor
          Found in plugins/sys/classes/yf_core_api.class.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 get_properties has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function get_properties($section = 'all')
              {
                  $props = [];
                  foreach ((array) $this->get_classes($section) as $_section => $modules) {
                      foreach ((array) $modules as $module) {
          Severity: Minor
          Found in plugins/sys/classes/yf_core_api.class.php - About 35 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 get_widgets has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function get_widgets($section = 'all', $prefix = 'widget__')
              {
                  $prefix_len = strlen($prefix);
                  $data = [];
                  foreach ((array) $this->get_all_hooks($section) as $module => $_hooks) {
          Severity: Minor
          Found in plugins/sys/classes/yf_core_api.class.php - About 35 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 get_methods has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function get_methods($section = 'all')
              {
                  $methods = [];
                  foreach ((array) $this->get_classes($section) as $_section => $modules) {
                      foreach ((array) $modules as $module) {
          Severity: Minor
          Found in plugins/sys/classes/yf_core_api.class.php - About 35 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 get_classes_by_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function get_classes_by_params($extra = [], &$paths = [])
              {
                  $prefix = isset($extra['prefix']) ? $extra['prefix'] : YF_PREFIX;
                  $suffix = isset($extra['suffix']) ? $extra['suffix'] : YF_CLS_EXT;
                  $folder = isset($extra['folder']) ? $extra['folder'] : $this->section_paths['core'];
          Severity: Minor
          Found in plugins/sys/classes/yf_core_api.class.php - About 35 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 get_hooks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public function get_hooks($hook_name, $section = 'all')
              {
                  $hooks = [];
                  foreach ((array) $this->get_all_hooks($section) as $module => $_hooks) {
                      foreach ((array) $_hooks as $name => $method_name) {
          Severity: Minor
          Found in plugins/sys/classes/yf_core_api.class.php - About 25 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 get_public_methods has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public function get_public_methods($section = 'all')
              {
                  $data = [];
                  foreach ((array) $this->get_methods($section) as $module => $methods) {
                      foreach ((array) $methods as $method) {
          Severity: Minor
          Found in plugins/sys/classes/yf_core_api.class.php - About 25 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 get_private_methods has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public function get_private_methods($section = 'all')
              {
                  $data = [];
                  foreach ((array) $this->get_methods($section) as $module => $methods) {
                      foreach ((array) $methods as $method) {
          Severity: Minor
          Found in plugins/sys/classes/yf_core_api.class.php - About 25 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 show_docs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public function show_docs(array $info)
              {
                  $tests = '';
                  if ($info['is_func']) {
                      $tests = _class('core_api')->get_function_tests($info['name']);
          Severity: Minor
          Found in plugins/sys/classes/yf_core_api.class.php - About 25 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

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

              public function get_function_docs($name)
              {
                  $docs_dir = YF_PATH . '.dev/docs/en/';
                  $f = $docs_dir . $name . '.stpl';
                  if (file_exists($f)) {
          Severity: Minor
          Found in plugins/sys/classes/yf_core_api.class.php and 1 other location - About 40 mins to fix
          plugins/sys/classes/yf_core_api.class.php on lines 451..459

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

          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_module_docs($name)
              {
                  $docs_dir = YF_PATH . '.dev/docs/en/';
                  $f = $docs_dir . $name . '.stpl';
                  if (file_exists($f)) {
          Severity: Minor
          Found in plugins/sys/classes/yf_core_api.class.php and 1 other location - About 40 mins to fix
          plugins/sys/classes/yf_core_api.class.php on lines 481..489

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

          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