.dev/tests/unit/class_assets_test.Test.php

Summary

Maintainability
F
2 wks
Test Coverage

File class_assets_test.Test.php has 790 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

require_once dirname(__DIR__) . '/yf_unit_tests_setup.php';

class class_assets_test extends PHPUnit\Framework\TestCase
Severity: Major
Found in .dev/tests/unit/class_assets_test.Test.php - About 1 day to fix

    Method test_config has 154 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function test_config()
        {
            $fake_lib1_url = _class('assets')->get_asset('jquery', 'js');
            $fake_lib1 = [
                'versions' => [
    Severity: Major
    Found in .dev/tests/unit/class_assets_test.Test.php - About 6 hrs to fix

      class_assets_test has 24 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class class_assets_test extends PHPUnit\Framework\TestCase
      // class class_assets_test extends yf\tests\wrapper
      {
          public static function setUpBeforeClass() : void
          {
      Severity: Minor
      Found in .dev/tests/unit/class_assets_test.Test.php - About 2 hrs to fix

        Function _helper_add_config has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            public function _helper_add_config($libs = [], $types = ['js', 'css'])
            {
                _class('assets')->clean_all();
                foreach ($libs as $name => $config) {
                    foreach ($types as $type) {
        Severity: Minor
        Found in .dev/tests/unit/class_assets_test.Test.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 test_recusrion3 has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function test_recusrion3()
            {
                $jquery_url = _class('assets')->get_asset('jquery', 'js');
                $url = $jquery_url;
                $url1 = $url . '?v=1';
        Severity: Minor
        Found in .dev/tests/unit/class_assets_test.Test.php - About 2 hrs to fix

          Method test_order8 has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function test_order8()
              {
                  $jquery_url = _class('assets')->get_asset('jquery', 'js');
                  $url = $jquery_url;
                  $url1 = $url . '?v=1';
          Severity: Minor
          Found in .dev/tests/unit/class_assets_test.Test.php - About 1 hr to fix

            Method test_order7 has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function test_order7()
                {
                    $jquery_url = _class('assets')->get_asset('jquery', 'js');
                    $url = $jquery_url;
                    $url1 = $url . '?v=1';
            Severity: Minor
            Found in .dev/tests/unit/class_assets_test.Test.php - About 1 hr to fix

              Method test_order6 has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function test_order6()
                  {
                      $jquery_url = _class('assets')->get_asset('jquery', 'js');
                      $url = $jquery_url;
                      $url1 = $url . '?v=1';
              Severity: Minor
              Found in .dev/tests/unit/class_assets_test.Test.php - About 1 hr to fix

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

                    public function test_order4()
                    {
                        $url = 'http://jquery.com/jquery-wp-content/themes/jquery.com/style.css';
                        $url1 = $url . '?v=1';
                        $url2 = $url . '?v=2';
                Severity: Minor
                Found in .dev/tests/unit/class_assets_test.Test.php - About 1 hr to fix

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

                      public function test_order5()
                      {
                          $jquery_url = _class('assets')->get_asset('jquery', 'js');
                          $url = $jquery_url;
                          $url1 = $url . '?v=1';
                  Severity: Minor
                  Found in .dev/tests/unit/class_assets_test.Test.php - About 1 hr to fix

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

                        public function test_order3()
                        {
                            $url = 'http://jquery.com/jquery-wp-content/themes/jquery.com/style.css';
                            $url1 = $url . '?v=1';
                            $url2 = $url . '?v=2';
                    Severity: Minor
                    Found in .dev/tests/unit/class_assets_test.Test.php - About 1 hr to fix

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

                          public function test_order1()
                          {
                              $url = 'http://jquery.com/jquery-wp-content/themes/jquery.com/style.css';
                              $url1 = $url . '?v=1';
                              $url2 = $url . '?v=2';
                      Severity: Minor
                      Found in .dev/tests/unit/class_assets_test.Test.php - About 1 hr to fix

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

                            public function test_order2()
                            {
                                $url = 'http://jquery.com/jquery-wp-content/themes/jquery.com/style.css';
                                $url1 = $url . '?v=1';
                                $url2 = $url . '?v=2';
                        Severity: Minor
                        Found in .dev/tests/unit/class_assets_test.Test.php - About 1 hr to fix

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

                              public function _helper_add_config($libs = [], $types = ['js', 'css'])
                              {
                                  _class('assets')->clean_all();
                                  foreach ($libs as $name => $config) {
                                      foreach ($types as $type) {
                          Severity: Minor
                          Found in .dev/tests/unit/class_assets_test.Test.php - About 1 hr to fix

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

                                public function test_recursion2()
                                {
                                    _class('assets')->clean_all();
                                    $fake_lib1_url = _class('assets')->get_asset('jquery', 'js') . '?123';
                                    $lib_name3 = __FUNCTION__ . '_fake_lib3';
                            Severity: Major
                            Found in .dev/tests/unit/class_assets_test.Test.php and 1 other location - About 2 days to fix
                            .dev/tests/unit/class_assets_test.Test.php on lines 499..525

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

                            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 test_recursion1()
                                {
                                    _class('assets')->clean_all();
                                    $fake_lib1_url = _class('assets')->get_asset('jquery', 'js') . '?123';
                                    $lib_name1 = __FUNCTION__ . '_fake_lib1';
                            Severity: Major
                            Found in .dev/tests/unit/class_assets_test.Test.php and 1 other location - About 2 days to fix
                            .dev/tests/unit/class_assets_test.Test.php on lines 528..554

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

                            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 test_strip_css_input()
                                {
                                    $this->assertEquals('#some_id { display:none; }', _class('assets')->_strip_css_input('<style>#some_id { display:none; }</style>'));
                                    $this->assertEquals('#some_id { display:none; }', _class('assets')->_strip_css_input('<style>#some_id { display:none; }'));
                                    $this->assertEquals('#some_id { display:none; }', _class('assets')->_strip_css_input('#some_id { display:none; }</style>'));
                            Severity: Major
                            Found in .dev/tests/unit/class_assets_test.Test.php and 1 other location - About 1 day to fix
                            .dev/tests/unit/class_assets_test.Test.php on lines 84..99

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

                            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 test_strip_js_input()
                                {
                                    $this->assertEquals('$(function(){})', _class('assets')->_strip_js_input('<script>$(function(){})</script>'));
                                    $this->assertEquals('$(function(){})', _class('assets')->_strip_js_input('<script>$(function(){})'));
                                    $this->assertEquals('$(function(){})', _class('assets')->_strip_js_input('$(function(){})</script>'));
                            Severity: Major
                            Found in .dev/tests/unit/class_assets_test.Test.php and 1 other location - About 1 day to fix
                            .dev/tests/unit/class_assets_test.Test.php on lines 102..117

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

                            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 3 locations. Consider refactoring.
                            Open

                                public function test_order3()
                                {
                                    $url = 'http://jquery.com/jquery-wp-content/themes/jquery.com/style.css';
                                    $url1 = $url . '?v=1';
                                    $url2 = $url . '?v=2';
                            Severity: Major
                            Found in .dev/tests/unit/class_assets_test.Test.php and 2 other locations - About 1 day to fix
                            .dev/tests/unit/class_assets_test.Test.php on lines 652..687
                            .dev/tests/unit/class_assets_test.Test.php on lines 690..725

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

                            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 3 locations. Consider refactoring.
                            Open

                                public function test_order1()
                                {
                                    $url = 'http://jquery.com/jquery-wp-content/themes/jquery.com/style.css';
                                    $url1 = $url . '?v=1';
                                    $url2 = $url . '?v=2';
                            Severity: Major
                            Found in .dev/tests/unit/class_assets_test.Test.php and 2 other locations - About 1 day to fix
                            .dev/tests/unit/class_assets_test.Test.php on lines 690..725
                            .dev/tests/unit/class_assets_test.Test.php on lines 728..763

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

                            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 3 locations. Consider refactoring.
                            Open

                                public function test_order2()
                                {
                                    $url = 'http://jquery.com/jquery-wp-content/themes/jquery.com/style.css';
                                    $url1 = $url . '?v=1';
                                    $url2 = $url . '?v=2';
                            Severity: Major
                            Found in .dev/tests/unit/class_assets_test.Test.php and 2 other locations - About 1 day to fix
                            .dev/tests/unit/class_assets_test.Test.php on lines 652..687
                            .dev/tests/unit/class_assets_test.Test.php on lines 728..763

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

                            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 4 locations. Consider refactoring.
                            Open

                                    $expected = implode(PHP_EOL, [
                                        '<script src="' . $jquery_url . '" type="text/javascript"></script>', // Appears first because of required config entry
                                        '<script src="' . $url1 . '" type="text/javascript"></script>', // main script url
                                        '<script src="' . $url2 . '" type="text/javascript"></script>', // main script url
                                        '<script src="' . $url3 . '" type="text/javascript"></script>', // main asset appears after js and jquery
                            Severity: Major
                            Found in .dev/tests/unit/class_assets_test.Test.php and 3 other locations - About 2 hrs to fix
                            .dev/tests/unit/class_assets_test.Test.php on lines 878..885
                            .dev/tests/unit/class_assets_test.Test.php on lines 924..931
                            .dev/tests/unit/class_assets_test.Test.php on lines 973..980

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

                            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 4 locations. Consider refactoring.
                            Open

                                    $expected = implode(PHP_EOL, [
                                        '<script src="' . $jquery_url . '" type="text/javascript"></script>', // Appears first because of required config entry
                                        '<script src="' . $url1 . '" type="text/javascript"></script>', // main script url
                                        '<script src="' . $url2 . '" type="text/javascript"></script>', // main script url
                                        '<script src="' . $url3 . '" type="text/javascript"></script>', // main asset appears after js and jquery
                            Severity: Major
                            Found in .dev/tests/unit/class_assets_test.Test.php and 3 other locations - About 2 hrs to fix
                            .dev/tests/unit/class_assets_test.Test.php on lines 602..609
                            .dev/tests/unit/class_assets_test.Test.php on lines 878..885
                            .dev/tests/unit/class_assets_test.Test.php on lines 924..931

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

                            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 4 locations. Consider refactoring.
                            Open

                                    $expected = implode(PHP_EOL, [
                                        '<script src="' . $url3 . '" type="text/javascript"></script>', // required js
                                        '<script src="' . $jquery_url . '" type="text/javascript"></script>', // Appears as requirement for inlined script, after required js
                                        '<script src="' . $url4 . '" type="text/javascript"></script>', // required asset appears after js and jquery
                                        '<script src="' . $url1 . '" type="text/javascript"></script>', // main script
                            Severity: Major
                            Found in .dev/tests/unit/class_assets_test.Test.php and 3 other locations - About 2 hrs to fix
                            .dev/tests/unit/class_assets_test.Test.php on lines 602..609
                            .dev/tests/unit/class_assets_test.Test.php on lines 924..931
                            .dev/tests/unit/class_assets_test.Test.php on lines 973..980

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

                            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 4 locations. Consider refactoring.
                            Open

                                    $expected = implode(PHP_EOL, [
                                        '<script src="' . $url1 . '" type="text/javascript"></script>', // main script url
                                        '<script src="' . $url2 . '" type="text/javascript"></script>', // main script url
                                        '<script src="' . $jquery_url . '" type="text/javascript"></script>', // Appears as requirement for inlined script, after required js
                                        '<script src="' . $url3 . '" type="text/javascript"></script>', // main asset appears after js and jquery
                            Severity: Major
                            Found in .dev/tests/unit/class_assets_test.Test.php and 3 other locations - About 2 hrs to fix
                            .dev/tests/unit/class_assets_test.Test.php on lines 602..609
                            .dev/tests/unit/class_assets_test.Test.php on lines 878..885
                            .dev/tests/unit/class_assets_test.Test.php on lines 973..980

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

                            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