functions/yf_common_funcs.php

Summary

Maintainability
F
4 days
Test Coverage

File yf_common_funcs.php has 612 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

require_once __DIR__ . '/yf_aliases.php';
require_once __DIR__ . '/yf_is_funcs.php';
require_once __DIR__ . '/yf_array_funcs.php';
Severity: Major
Found in functions/yf_common_funcs.php - About 1 day to fix

    Function _attrs has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

        function _attrs($extra, $names)
        {
            $body = [];
            $a = [];
            foreach ((array) $names as $name) {
    Severity: Minor
    Found in functions/yf_common_funcs.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

    Function my_array_merge has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        function my_array_merge($a1, $a2)
        {
            foreach ((array) $a2 as $k => $v) {
                if (isset($a1[$k]) && is_array($a1[$k])) {
                    if (is_array($a2[$k])) {
    Severity: Minor
    Found in functions/yf_common_funcs.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 _attrs_string2array has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        function _attrs_string2array($string = '', $strip_quotes = true)
        {
            $output_array = [];
            if ( ! is_string($string)) {
                return [];
    Severity: Minor
    Found in functions/yf_common_funcs.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 _attrs has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function _attrs($extra, $names)
        {
            $body = [];
            $a = [];
            foreach ((array) $names as $name) {
    Severity: Minor
    Found in functions/yf_common_funcs.php - About 1 hr to fix

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

          function load_db_class()
          {
              static $_loaded_class;
              if ($_loaded_class) {
                  return $_loaded_class;
      Severity: Minor
      Found in functions/yf_common_funcs.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 class_basename has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          function class_basename($class, $prefix = '', $suffix = '')
          {
              $class = is_object($class) ? get_class($class) : $class;
              $class = basename(str_replace('\\', '/', $class));
              $prefixes = [
      Severity: Minor
      Found in functions/yf_common_funcs.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 wildcard_compare has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          function wildcard_compare($wild, $string)
          {
              if (is_array($wild)) {
                  $func = __FUNCTION__;
                  foreach ($wild as $_wild) {
      Severity: Minor
      Found in functions/yf_common_funcs.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

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

          function _attr_class_clean($class = '')
          {
              if ( ! strlen($class) || strpos($class, ' ') === false) {
                  return $class;
              }
      Severity: Minor
      Found in functions/yf_common_funcs.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

      Method _show_avatar has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          function _show_avatar($user_id = 0, $user_name = '', $as_link = 0, $is_middle = 0, $only_img_src = 0, $force_link = '')
      Severity: Minor
      Found in functions/yf_common_funcs.php - About 45 mins to fix

        Method _gen_dir_path has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            function _gen_dir_path($id, $path = '', $make = false, $dir_mode = 0755, $create_index_htmls = 1)
        Severity: Minor
        Found in functions/yf_common_funcs.php - About 35 mins to fix

          Function cache_memcached_connect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              function cache_memcached_connect($params = [])
              {
                  global $memcache_obj, $CONF;
                  if (isset($memcache_obj)) {
                      return $memcache_obj;
          Severity: Minor
          Found in functions/yf_common_funcs.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 my_explode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              function my_explode($string = '', $divider = PHP_EOL)
              {
                  $result = explode($divider, trim($string));
                  foreach ((array) $result as $k => $v) {
                      $v = trim($v);
          Severity: Minor
          Found in functions/yf_common_funcs.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 obj2arr has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              function obj2arr(&$obj)
              {
                  $obj = (array) $obj;
                  foreach ($obj as &$v) {
                      if (is_array($v)) {
          Severity: Minor
          Found in functions/yf_common_funcs.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 _htmlchars has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              function _htmlchars($str = '')
              {
                  if (is_array($str)) {
                      foreach ((array) $str as $k => $v) {
                          $str[$k] = _htmlchars($v);
          Severity: Minor
          Found in functions/yf_common_funcs.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

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

          if ( ! function_exists('my_array_merge')) {
              function my_array_merge($a1, $a2)
              {
                  foreach ((array) $a2 as $k => $v) {
                      if (isset($a1[$k]) && is_array($a1[$k])) {
          Severity: Major
          Found in functions/yf_common_funcs.php and 1 other location - About 5 hrs to fix
          .dev/install/skel_basic/config/project_conf.php on lines 26..48

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

          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 ( ! function_exists('_var_export')) {
              function _var_export($data)
              {
                  $str = var_export($data, 1);
                  $str = str_replace('  ', "\t", $str);
          Severity: Major
          Found in functions/yf_common_funcs.php and 1 other location - About 3 hrs to fix
          .dev/scripts/countries/get_latest_countries.php on lines 24..35

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

          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