plugins/assets/classes/yf_assets.class.php

Summary

Maintainability
F
3 wks
Test Coverage

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

<?php

// TODO: compare versions with require_php_lib('php_semver')
// TODO: decide with images: jpeg, png, gif, sprites
// TODO: requirejs integration, auto-generate its config with switcher on/off
Severity: Major
Found in plugins/assets/classes/yf_assets.class.php - About 5 days to fix

    yf_assets has 81 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class yf_assets
    {
        /** @array */
        public $supported_asset_types = [
            'jquery', 'js', 'css', 'less', 'sass', 'coffee', 'bundle', 'asset', /*, 'img', 'font'*/
    Severity: Major
    Found in plugins/assets/classes/yf_assets.class.php - About 1 day to fix

      Function add has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
      Open

          public function add($content, $asset_type = 'bundle', $content_type_hint = 'auto', $params = [])
          {
              if (DEBUG_MODE) {
                  $trace = main()->trace_string();
              }
      Severity: Minor
      Found in plugins/assets/classes/yf_assets.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 show has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
      Open

          public function show($out_type, $params = [])
          {
              if ( ! $out_type || ! in_array($out_type, $this->supported_out_types)) {
                  throw new Exception('Assets: unsupported out content type: ' . $out_type);
                  return null;
      Severity: Minor
      Found in plugins/assets/classes/yf_assets.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 _get_all_content_for_out has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
      Open

          public function _get_all_content_for_out($out_type, $params = [])
          {
              $is_ajax = main()->is_ajax();
              // Move down inlined content
              $all_content = $this->get_content($out_type);
      Severity: Minor
      Found in plugins/assets/classes/yf_assets.class.php - About 6 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 html_out has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
      Open

          public function html_out($out_type, $content_type, $str, $params = [])
          {
              if ( ! $out_type || ! $content_type || ! strlen($str)) {
                  return false;
              }
      Severity: Minor
      Found in plugins/assets/classes/yf_assets.class.php - About 6 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_asset_from_bower has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          public function get_asset_from_bower($name, $version = 'master', $asset_data = [], $asset_type)
          {
              if ( ! $name || ! $asset_data || ! isset($asset_data[$asset_type])) {
                  return false;
              }
      Severity: Minor
      Found in plugins/assets/classes/yf_assets.class.php - About 4 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 110 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function show($out_type, $params = [])
          {
              if ( ! $out_type || ! in_array($out_type, $this->supported_out_types)) {
                  throw new Exception('Assets: unsupported out content type: ' . $out_type);
                  return null;
      Severity: Major
      Found in plugins/assets/classes/yf_assets.class.php - About 4 hrs to fix

        Method add has 107 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function add($content, $asset_type = 'bundle', $content_type_hint = 'auto', $params = [])
            {
                if (DEBUG_MODE) {
                    $trace = main()->trace_string();
                }
        Severity: Major
        Found in plugins/assets/classes/yf_assets.class.php - About 4 hrs to fix

          Function _add_bundle has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              public function _add_bundle($_content, $_params = [])
              {
                  if ( ! $_content) {
                      return false;
                  }
          Severity: Minor
          Found in plugins/assets/classes/yf_assets.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 html_out has 78 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function html_out($out_type, $content_type, $str, $params = [])
              {
                  if ( ! $out_type || ! $content_type || ! strlen($str)) {
                      return false;
                  }
          Severity: Major
          Found in plugins/assets/classes/yf_assets.class.php - About 3 hrs to fix

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

                public function _combine_content(array $out, $out_type, array $to_combine, $combined_file, array $md5_inside_combined)
                {
                    if ( ! file_exists($combined_file)) {
                        $divider = PHP_EOL;
                        if ($out_type === 'js') {
            Severity: Minor
            Found in plugins/assets/classes/yf_assets.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 get_asset has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

                public function get_asset($name, $asset_type, $version = '')
                {
                    if ( ! $name) {
                        return null;
                    }
            Severity: Minor
            Found in plugins/assets/classes/yf_assets.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 _css_urls_rewrite_and_save has 75 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function _css_urls_rewrite_and_save($content, $content_url, $cache_path, $content_type = 'url', $orig_content = '')
                {
                    $_this = $this;
                    $self_func = __FUNCTION__;
                    return preg_replace_callback('~url\([\'"\s]*(?P<url>[^\'"\)]+?)[\'"\s]*\)~ims', function ($m) use ($_this, $content_url, $cache_path, $content_type, $orig_content, $self_func) {
            Severity: Major
            Found in plugins/assets/classes/yf_assets.class.php - About 3 hrs to fix

              Method _get_all_content_for_out has 75 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function _get_all_content_for_out($out_type, $params = [])
                  {
                      $is_ajax = main()->is_ajax();
                      // Move down inlined content
                      $all_content = $this->get_content($out_type);
              Severity: Major
              Found in plugins/assets/classes/yf_assets.class.php - About 3 hrs to fix

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

                    public function _add_asset($_content, $asset_type, $_params = [])
                    {
                        if ( ! $_content) {
                            return false;
                        }
                Severity: Minor
                Found in plugins/assets/classes/yf_assets.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_asset_from_bower has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function get_asset_from_bower($name, $version = 'master', $asset_data = [], $asset_type)
                    {
                        if ( ! $name || ! $asset_data || ! isset($asset_data[$asset_type])) {
                            return false;
                        }
                Severity: Major
                Found in plugins/assets/classes/yf_assets.class.php - About 2 hrs to fix

                  Method _add_bundle has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function _add_bundle($_content, $_params = [])
                      {
                          if ( ! $_content) {
                              return false;
                          }
                  Severity: Major
                  Found in plugins/assets/classes/yf_assets.class.php - About 2 hrs to fix

                    Method _combine_content has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function _combine_content(array $out, $out_type, array $to_combine, $combined_file, array $md5_inside_combined)
                        {
                            if ( ! file_exists($combined_file)) {
                                $divider = PHP_EOL;
                                if ($out_type === 'js') {
                    Severity: Major
                    Found in plugins/assets/classes/yf_assets.class.php - About 2 hrs to fix

                      Method _add_asset has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function _add_asset($_content, $asset_type, $_params = [])
                          {
                              if ( ! $_content) {
                                  return false;
                              }
                      Severity: Major
                      Found in plugins/assets/classes/yf_assets.class.php - About 2 hrs to fix

                        Function _sub_add has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function _sub_add($info, $asset_type, $_params = [])
                            {
                                if ( ! $info) {
                                    return false;
                                }
                        Severity: Minor
                        Found in plugins/assets/classes/yf_assets.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 _url_control has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function _url_control()
                            {
                                if ( ! $this->ALLOW_URL_CONTROL) {
                                    return false;
                                }
                        Severity: Minor
                        Found in plugins/assets/classes/yf_assets.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 set_cache has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function set_cache($out_type, $md5, $data = [])
                            {
                                if ( ! $this->USE_CACHE) {
                                    return false;
                                }
                        Severity: Minor
                        Found in plugins/assets/classes/yf_assets.class.php - About 1 hr to fix

                          Function filters_process_input has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function filters_process_input($in, $filters = [], $params = [])
                              {
                                  if (is_array($in)) {
                                      $out = [];
                                      $func = __FUNCTION__;
                          Severity: Minor
                          Found in plugins/assets/classes/yf_assets.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_asset has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function get_asset($name, $asset_type, $version = '')
                              {
                                  if ( ! $name) {
                                      return null;
                                  }
                          Severity: Minor
                          Found in plugins/assets/classes/yf_assets.class.php - About 1 hr to fix

                            Method _url_control has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function _url_control()
                                {
                                    if ( ! $this->ALLOW_URL_CONTROL) {
                                        return false;
                                    }
                            Severity: Minor
                            Found in plugins/assets/classes/yf_assets.class.php - About 1 hr to fix

                              Function detect_content_type has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function detect_content_type($asset_type, $content = '')
                                  {
                                      $content = trim($content);
                                      $type = false;
                                      if (isset($this->assets[$content])) {
                              Severity: Minor
                              Found in plugins/assets/classes/yf_assets.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_asset_from_github has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function get_asset_from_github($name, $version = 'master', $asset_data = [], $asset_type)
                                  {
                                      if ( ! $name || ! $asset_data || ! isset($asset_data[$asset_type])) {
                                          return false;
                                      }
                              Severity: Minor
                              Found in plugins/assets/classes/yf_assets.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 set_cache has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function set_cache($out_type, $md5, $data = [])
                                  {
                                      if ( ! $this->USE_CACHE) {
                                          return false;
                                      }
                              Severity: Minor
                              Found in plugins/assets/classes/yf_assets.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_asset_from_cdn has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function get_asset_from_cdn($name, $version = 'master', $asset_data = [], $asset_type)
                                  {
                                      if ( ! $name || ! $asset_data || ! isset($asset_data[$asset_type]) || ! $asset_data['url']) {
                                          return false;
                                      }
                              Severity: Minor
                              Found in plugins/assets/classes/yf_assets.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 load_predefined_assets has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function load_predefined_assets($force = false)
                                  {
                                      // Cleanup previously filled assets
                                      if ($force) {
                                          $this->assets = [];
                              Severity: Minor
                              Found in plugins/assets/classes/yf_assets.class.php - About 1 hr to fix

                                Method _cache_dir has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function _cache_dir($out_type, $asset_name = '', $version = '')
                                    {
                                        if ( ! is_string($this->CACHE_DIR_TPL) && is_callable($this->CACHE_DIR_TPL)) {
                                            $func = $this->CACHE_DIR_TPL;
                                            $cache_dir = $func($out_type, $asset_name, $version, $this);
                                Severity: Minor
                                Found in plugins/assets/classes/yf_assets.class.php - About 1 hr to fix

                                  Consider simplifying this complex logical expression.
                                  Open

                                              if ($method == 'bower' && $this->ALLOW_GET_FROM_BOWER && $_files) {
                                                  return $this->get_asset_from_bower($_name, $_version, $data, $asset_type);
                                              } elseif ($method == 'github' && $this->ALLOW_GET_FROM_GITHUB && $_files) {
                                                  return $this->get_asset_from_github($_name, $_version, $data, $asset_type);
                                              } elseif ($method == 'cdn' && $this->ALLOW_GET_FROM_CDN && isset($asset_data[$method]) && isset($asset_data[$method][$asset_type])) {
                                  Severity: Critical
                                  Found in plugins/assets/classes/yf_assets.class.php - About 1 hr to fix

                                    Method filters_get_avail has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        public function filters_get_avail()
                                        {
                                            if (isset($this->_avail_filters)) {
                                                return $this->_avail_filters;
                                            }
                                    Severity: Minor
                                    Found in plugins/assets/classes/yf_assets.class.php - About 1 hr to fix

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

                                          public function get_asset_from_cdn($name, $version = 'master', $asset_data = [], $asset_type)
                                          {
                                              if ( ! $name || ! $asset_data || ! isset($asset_data[$asset_type]) || ! $asset_data['url']) {
                                                  return false;
                                              }
                                      Severity: Minor
                                      Found in plugins/assets/classes/yf_assets.class.php - About 1 hr to fix

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

                                            public function _sub_add($info, $asset_type, $_params = [])
                                            {
                                                if ( ! $info) {
                                                    return false;
                                                }
                                        Severity: Minor
                                        Found in plugins/assets/classes/yf_assets.class.php - About 1 hr to fix

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

                                              public function _url_get_contents($url)
                                              {
                                                  if ( ! strlen($url)) {
                                                      return false;
                                                  }
                                          Severity: Minor
                                          Found in plugins/assets/classes/yf_assets.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 filters_get_avail has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              public function filters_get_avail()
                                              {
                                                  if (isset($this->_avail_filters)) {
                                                      return $this->_avail_filters;
                                                  }
                                          Severity: Minor
                                          Found in plugins/assets/classes/yf_assets.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_combined_version has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                              public function _get_combined_version($out_type = '')
                                              {
                                                  if ( ! is_string($this->COMBINED_VERSION_TPL) && is_callable($this->COMBINED_VERSION_TPL)) {
                                                      $func = $this->COMBINED_VERSION_TPL;
                                                      $version = $func($out_type, $this);
                                          Severity: Minor
                                          Found in plugins/assets/classes/yf_assets.class.php - About 1 hr to fix

                                            Method _url_get_contents has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                            Open

                                                public function _url_get_contents($url)
                                                {
                                                    if ( ! strlen($url)) {
                                                        return false;
                                                    }
                                            Severity: Minor
                                            Found in plugins/assets/classes/yf_assets.class.php - About 1 hr to fix

                                              Method get_asset_from_github has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                              Open

                                                  public function get_asset_from_github($name, $version = 'master', $asset_data = [], $asset_type)
                                                  {
                                                      if ( ! $name || ! $asset_data || ! isset($asset_data[$asset_type])) {
                                                          return false;
                                                      }
                                              Severity: Minor
                                              Found in plugins/assets/classes/yf_assets.class.php - About 1 hr to fix

                                                Method filters_process_input has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                                Open

                                                    public function filters_process_input($in, $filters = [], $params = [])
                                                    {
                                                        if (is_array($in)) {
                                                            $out = [];
                                                            $func = __FUNCTION__;
                                                Severity: Minor
                                                Found in plugins/assets/classes/yf_assets.class.php - About 1 hr to fix

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

                                                      public function set_content($asset_type, $md5, $content_type, $content, $params = [])
                                                      {
                                                          if (isset($this->content[$asset_type][$md5])) {
                                                              return $this->content[$asset_type][$md5];
                                                          }
                                                  Severity: Minor
                                                  Found in plugins/assets/classes/yf_assets.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 _cached_url_get_mtime has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      public function _cached_url_get_mtime($str = '')
                                                      {
                                                          $url_param = 'yfmt';
                                                          if ( ! $this->CACHE_OUT_ADD_MTIME || ! strlen($str) || false !== strpos($str, $url_param . '=')) {
                                                              return false;
                                                  Severity: Minor
                                                  Found in plugins/assets/classes/yf_assets.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 set_content has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                                  Open

                                                      public function set_content($asset_type, $md5, $content_type, $content, $params = [])
                                                      {
                                                          if (isset($this->content[$asset_type][$md5])) {
                                                              return $this->content[$asset_type][$md5];
                                                          }
                                                  Severity: Minor
                                                  Found in plugins/assets/classes/yf_assets.class.php - About 1 hr to fix

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

                                                        public function filters_process_added($asset_type, $params = [])
                                                        {
                                                            if ( ! $asset_type) {
                                                                return false;
                                                            }
                                                    Severity: Minor
                                                    Found in plugins/assets/classes/yf_assets.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

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

                                                        public function load_predefined_assets($force = false)
                                                        {
                                                            // Cleanup previously filled assets
                                                            if ($force) {
                                                                $this->assets = [];
                                                    Severity: Minor
                                                    Found in plugins/assets/classes/yf_assets.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

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

                                                        public function _js_map_save($content, $content_url, $cache_path)
                                                        {
                                                            $map_ext = '.map';
                                                            $map_url = '';
                                                            // Parse inline map url suggest, example: //# sourceMappingURL=lightbox.min.map
                                                    Severity: Minor
                                                    Found in plugins/assets/classes/yf_assets.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 find_asset_type_for_module has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        public function find_asset_type_for_module($asset_type, $module = '')
                                                        {
                                                            if ( ! $module) {
                                                                $module = $_GET['object'];
                                                            }
                                                    Severity: Minor
                                                    Found in plugins/assets/classes/yf_assets.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

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

                                                        public function _css_urls_rewrite_and_save($content, $content_url, $cache_path, $content_type = 'url', $orig_content = '')
                                                    Severity: Minor
                                                    Found in plugins/assets/classes/yf_assets.class.php - About 35 mins to fix

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

                                                          public function _combine_content(array $out, $out_type, array $to_combine, $combined_file, array $md5_inside_combined)
                                                      Severity: Minor
                                                      Found in plugins/assets/classes/yf_assets.class.php - About 35 mins to fix

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

                                                            public function set_content($asset_type, $md5, $content_type, $content, $params = [])
                                                        Severity: Minor
                                                        Found in plugins/assets/classes/yf_assets.class.php - About 35 mins to fix

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

                                                              public function _get_absolute_path($path)
                                                              {
                                                                  $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
                                                                  $absolutes = [];
                                                                  foreach ($parts as $part) {
                                                          Severity: Minor
                                                          Found in plugins/assets/classes/yf_assets.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

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                  return $cache[$name];
                                                          Severity: Major
                                                          Found in plugins/assets/classes/yf_assets.class.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                    return $data;
                                                            Severity: Major
                                                            Found in plugins/assets/classes/yf_assets.class.php - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                              return false;
                                                              Severity: Major
                                                              Found in plugins/assets/classes/yf_assets.class.php - About 30 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                                    return null;
                                                                Severity: Major
                                                                Found in plugins/assets/classes/yf_assets.class.php - About 30 mins to fix

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                                  return $content;
                                                                  Severity: Major
                                                                  Found in plugins/assets/classes/yf_assets.class.php - About 30 mins to fix

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                            return file_put_contents($map_path, $map_content);
                                                                    Severity: Major
                                                                    Found in plugins/assets/classes/yf_assets.class.php - About 30 mins to fix

                                                                      Avoid too many return statements within this method.
                                                                      Open

                                                                                          return null;
                                                                      Severity: Major
                                                                      Found in plugins/assets/classes/yf_assets.class.php - About 30 mins to fix

                                                                        Avoid too many return statements within this method.
                                                                        Open

                                                                                return $cache_path;
                                                                        Severity: Major
                                                                        Found in plugins/assets/classes/yf_assets.class.php - About 30 mins to fix

                                                                          Avoid too many return statements within this method.
                                                                          Open

                                                                                          return $this->get_asset_from_cdn($name, $_version, $data, $asset_type);
                                                                          Severity: Major
                                                                          Found in plugins/assets/classes/yf_assets.class.php - About 30 mins to fix

                                                                            Function _cache_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                            Open

                                                                                public function _cache_name($out_type, $md5, $data = [])
                                                                                {
                                                                                    $content = $data['content'];
                                                                                    $content_type = $data['content_type'];
                                                                                    $_name = '';
                                                                            Severity: Minor
                                                                            Found in plugins/assets/classes/yf_assets.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

                                                                                    foreach ((array) $files as $from => $to) {
                                                                                        if (is_numeric($from)) {
                                                                                            $from = $to;
                                                                                        }
                                                                                        $to_path = rtrim($target_dir, '/') . '/' . ltrim($to, '/');
                                                                            Severity: Major
                                                                            Found in plugins/assets/classes/yf_assets.class.php and 1 other location - About 7 hrs to fix
                                                                            plugins/assets/classes/yf_assets.class.php on lines 732..747

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

                                                                            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) $files as $from => $to) {
                                                                                        if (is_numeric($from)) {
                                                                                            $from = $to;
                                                                                        }
                                                                                        $to_path = rtrim($target_dir, '/') . '/' . ltrim($to, '/');
                                                                            Severity: Major
                                                                            Found in plugins/assets/classes/yf_assets.class.php and 1 other location - About 7 hrs to fix
                                                                            plugins/assets/classes/yf_assets.class.php on lines 775..790

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

                                                                            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 init_css($force = false)
                                                                                {
                                                                                    if ($this->_init_css_done && ! $force) {
                                                                                        return false;
                                                                                    }
                                                                            Severity: Major
                                                                            Found in plugins/assets/classes/yf_assets.class.php and 1 other location - About 5 hrs to fix
                                                                            plugins/assets/classes/yf_assets.class.php on lines 322..340

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

                                                                            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 init_js($force = false)
                                                                                {
                                                                                    if ($this->_init_js_done && ! $force) {
                                                                                        return false;
                                                                                    }
                                                                            Severity: Major
                                                                            Found in plugins/assets/classes/yf_assets.class.php and 1 other location - About 5 hrs to fix
                                                                            plugins/assets/classes/yf_assets.class.php on lines 346..364

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

                                                                            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 _strip_js_input($str)
                                                                                {
                                                                                    // Extracting url from <script src="path.to/scripts.js"></script>
                                                                                    $str = preg_replace_callback('~<script[\s]+[^>]*src=["\']([^"\']+?)["\'][^>]*>~ims', function ($m) {
                                                                                        return $m[1];
                                                                            Severity: Major
                                                                            Found in plugins/assets/classes/yf_assets.class.php and 1 other location - About 2 hrs to fix
                                                                            plugins/assets/classes/yf_assets.class.php on lines 2225..2240

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

                                                                            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 _strip_css_input($str)
                                                                                {
                                                                                    // Extracting url from <link rel="stylesheet" href="path.to/style.css">
                                                                                    $str = preg_replace_callback('~<link[\s]+[^>]*href=["\']([^"\']+?)["\'][^>]*>~ims', function ($m) {
                                                                                        return $m[1];
                                                                            Severity: Major
                                                                            Found in plugins/assets/classes/yf_assets.class.php and 1 other location - About 2 hrs to fix
                                                                            plugins/assets/classes/yf_assets.class.php on lines 2246..2261

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

                                                                            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 ($this->INLINE_ASSETS_USE_DATA_URI && $content_type === 'inline') {
                                                                                            $content_type = 'url';
                                                                                            $params['href'] = 'data:' . $params['type'] . ';base64,' . base64_encode($this->_strip_css_input($str));
                                                                                        } elseif ($this->FILE_ASSETS_USE_DATA_URI && strlen($str) <= $this->FILE_ASSETS_DATA_URI_MAX_SIZE) {
                                                                                            $content_type = 'url';
                                                                            Severity: Major
                                                                            Found in plugins/assets/classes/yf_assets.class.php and 1 other location - About 2 hrs to fix
                                                                            plugins/assets/classes/yf_assets.class.php on lines 2133..2139

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

                                                                            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 ($this->INLINE_ASSETS_USE_DATA_URI && $content_type === 'inline') {
                                                                                            $content_type = 'url';
                                                                                            $params['src'] = 'data:' . $params['type'] . ';base64,' . base64_encode($this->_strip_js_input($str));
                                                                                        } elseif ($this->FILE_ASSETS_USE_DATA_URI && strlen($str) <= $this->FILE_ASSETS_DATA_URI_MAX_SIZE) {
                                                                                            $content_type = 'url';
                                                                            Severity: Major
                                                                            Found in plugins/assets/classes/yf_assets.class.php and 1 other location - About 2 hrs to fix
                                                                            plugins/assets/classes/yf_assets.class.php on lines 2164..2170

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

                                                                            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_less_content($params = [])
                                                                                {
                                                                                    if ( ! $this->ALLOW_CONTENT_LESS) {
                                                                                        return [];
                                                                                    }
                                                                            Severity: Major
                                                                            Found in plugins/assets/classes/yf_assets.class.php and 1 other location - About 2 hrs to fix
                                                                            plugins/assets/classes/yf_assets.class.php on lines 1303..1320

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

                                                                            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_sass_content($params = [])
                                                                                {
                                                                                    if ( ! $this->ALLOW_CONTENT_SASS) {
                                                                                        return [];
                                                                                    }
                                                                            Severity: Major
                                                                            Found in plugins/assets/classes/yf_assets.class.php and 1 other location - About 2 hrs to fix
                                                                            plugins/assets/classes/yf_assets.class.php on lines 1326..1343

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

                                                                            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