antaresproject/core

View on GitHub
src/utils/asset/src/JSMin.php

Summary

Maintainability
F
3 days
Test Coverage

Function action has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

    protected function action($command)
    {
        // make sure we don't compress "a + ++b" to "a+++b", etc.
        if ($command === self::ACTION_DELETE_A_B && $this->b === ' ' && ($this->a === '+' || $this->a === '-')) {
            // Note: we're at an addition/substraction operator; the inputIndex
Severity: Minor
Found in src/utils/asset/src/JSMin.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 min has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    public function min()
    {
        if ($this->output !== '') { // min already run
            return $this->output;
        }
Severity: Minor
Found in src/utils/asset/src/JSMin.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 action has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function action($command)
    {
        // make sure we don't compress "a + ++b" to "a+++b", etc.
        if ($command === self::ACTION_DELETE_A_B && $this->b === ' ' && ($this->a === '+' || $this->a === '-')) {
            // Note: we're at an addition/substraction operator; the inputIndex
Severity: Major
Found in src/utils/asset/src/JSMin.php - About 3 hrs to fix

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

        protected function consumeMultipleLineComment()
        {
            $this->get();
            $comment = '';
            for (;;) {
    Severity: Minor
    Found in src/utils/asset/src/JSMin.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

    File JSMin.php has 279 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    /**
     * Part of the Antares package.
     *
    Severity: Minor
    Found in src/utils/asset/src/JSMin.php - About 2 hrs to fix

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

          public function min()
          {
              if ($this->output !== '') { // min already run
                  return $this->output;
              }
      Severity: Minor
      Found in src/utils/asset/src/JSMin.php - About 1 hr to fix

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

            protected function isRegexpLiteral()
            {
                if (false !== strpos("(,=:[!&|?+-~*{;", $this->a)) {
                    // we can't divide after these tokens
                    return true;
        Severity: Minor
        Found in src/utils/asset/src/JSMin.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

        Avoid deeply nested control flow statements.
        Open

                                    for (;;) {
                                        $this->output .= $this->a;
                                        $this->a = $this->get();
                                        $pattern .= $this->a;
                                        if ($this->a === ']') {
        Severity: Major
        Found in src/utils/asset/src/JSMin.php - About 45 mins to fix

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

              protected function get()
              {
                  $c               = $this->lookAhead;
                  $this->lookAhead = null;
                  if ($c === null) {
          Severity: Minor
          Found in src/utils/asset/src/JSMin.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 true;
          Severity: Major
          Found in src/utils/asset/src/JSMin.php - About 30 mins to fix

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

                protected function consumeSingleLineComment()
                {
                    $comment = '';
                    while (true) {
                        $get = $this->get();
            Severity: Minor
            Found in src/utils/asset/src/JSMin.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

            There are no issues that match your filters.

            Category
            Status