elboletaire/less-cake-plugin

View on GitHub

Showing 26 of 26 total issues

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

    protected function prepareInputFilesForParsing(array $input = [])
    {
        $parse = [];
        foreach ($input as $in) {
            $less = realpath(WWW_ROOT . $in);
Severity: Minor
Found in src/View/Helper/LessHelper.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 setOptions has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function setOptions(array $options)
    {
        // @codeCoverageIgnoreStart
        $this->parserDefaults = array_merge($this->parserDefaults, [
            // The import callback ensures that if a file is not found in the
Severity: Minor
Found in src/View/Helper/LessHelper.php - About 1 hr to fix

    Method testLess has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function testLess()
        {
            $options = [
                'cache' => false,
                'parser' => ['sourceMap' => false]
    Severity: Minor
    Found in tests/TestCase/View/Helper/LessHelperTest.php - About 1 hr to fix

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

          public function fetch(array $options = [], array $modifyVars = [])
          {
              if (empty($options['overwrite'])) {
                  $options['overwrite'] = true;
              }
      Severity: Minor
      Found in src/View/Helper/LessHelper.php - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          public function less($less = 'styles.less', array $options = [], array $modifyVars = [])
          {
              $options = $this->setOptions($options);
              $less    = (array)$less;
      
      
      Severity: Minor
      Found in src/View/Helper/LessHelper.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 $this->jsBlock($less, $options);
      Severity: Major
      Found in src/View/Helper/LessHelper.php - About 30 mins to fix

        Missing class import via use statement (line '246', column '22').
        Open

                $class = new \ReflectionClass('Less\View\Helper\LessHelper');

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

        Missing class import via use statement (line '218', column '22').
        Open

                $lessc = new \Less_Parser($options);
        Severity: Minor
        Found in src/View/Helper/LessHelper.php by phpmd

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

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

            protected function setOptions(array $options)
            {
                // @codeCoverageIgnoreStart
                $this->parserDefaults = array_merge($this->parserDefaults, [
                    // The import callback ensures that if a file is not found in the
        Severity: Minor
        Found in src/View/Helper/LessHelper.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

        Avoid using static access to class '\Cake\Core\Configure' in method 'testLessWithNotExistingFiles'.
        Open

                Configure::write('debug', 0);

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class '\Less_Cache' in method 'compile'.
        Open

                    return \Less_Cache::Get($parse, $options, $modifyVars);
        Severity: Minor
        Found in src/View/Helper/LessHelper.php by phpmd

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid assigning values to variables in if clauses and the like (line '290', column '21').
        Open

            protected function setOptions(array $options)
            {
                // @codeCoverageIgnoreStart
                $this->parserDefaults = array_merge($this->parserDefaults, [
                    // The import callback ensures that if a file is not found in the
        Severity: Minor
        Found in src/View/Helper/LessHelper.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

        Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

        Avoid using static access to class '\Cake\Core\Plugin' in method 'pluginAssetFile'.
        Open

                if ($plugin && Plugin::loaded($plugin)) {
        Severity: Minor
        Found in src/View/Helper/LessHelper.php by phpmd

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class '\Cake\Core\Configure' in method 'testLessDefaultOptions'.
        Open

                Configure::write('debug', 0);

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class '\Cake\Log\Log' in method 'less'.
        Open

                    Log::write('error', "Error compiling less file: " . $this->error);
        Severity: Minor
        Found in src/View/Helper/LessHelper.php by phpmd

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class '\Cake\Core\Configure' in method 'testLessEnablesSourceMap'.
        Open

                Configure::write('debug', 1);

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class '\Cake\Core\Plugin' in method 'pluginAssetFile'.
        Open

                    return realpath(Plugin::path($plugin) . 'webroot' . DS . $basefile);
        Severity: Minor
        Found in src/View/Helper/LessHelper.php by phpmd

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class '\Cake\Core\Configure' in method 'less'.
        Open

                    if (Configure::read('debug')) {
        Severity: Minor
        Found in src/View/Helper/LessHelper.php by phpmd

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class '\Cake\Utility\Inflector' in method 'assetSplit'.
        Open

                $plugin   = Inflector::camelize(array_shift($exploded));
        Severity: Minor
        Found in src/View/Helper/LessHelper.php by phpmd

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class '\Cake\Core\Configure' in method 'setOptions'.
        Open

                if (Configure::read('debug') && !isset($options['parser']['sourceMap'])) {
        Severity: Minor
        Found in src/View/Helper/LessHelper.php by phpmd

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Severity
        Category
        Status
        Source
        Language