MAXakaWIZARD/xls-writer

View on GitHub
src/FormulaParser.php

Summary

Maintainability
D
2 days
Test Coverage

File FormulaParser.php has 437 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Xls;

class FormulaParser
Severity: Minor
Found in src/FormulaParser.php - About 6 hrs to fix

    FormulaParser has 40 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class FormulaParser
    {
        /**
         * The index of the character we are currently looking at
         * @var integer
    Severity: Minor
    Found in src/FormulaParser.php - About 5 hrs to fix

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

          protected function fact()
          {
              if ($this->currentToken == Token::TOKEN_OPEN) {
                  $this->advance(); // eat the "("
      
      
      Severity: Minor
      Found in src/FormulaParser.php - About 1 hr to fix

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

            protected function getRangeSheets($extRef)
            {
                $extRef = $this->removeTrailingQuotes($extRef);
        
                // Check if there is a sheet range eg., Sheet1:Sheet2.
        Severity: Minor
        Found in src/FormulaParser.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 func has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function func()
            {
                $numArgs = 0; // number of arguments received
                $function = strtoupper($this->currentToken);
                $result = ''; // initialize result
        Severity: Minor
        Found in src/FormulaParser.php - About 1 hr to fix

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

              protected function advance()
              {
                  $token = '';
          
                  $position = $this->eatWhitespace();
          Severity: Minor
          Found in src/FormulaParser.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 func has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function func()
              {
                  $numArgs = 0; // number of arguments received
                  $function = strtoupper($this->currentToken);
                  $result = ''; // initialize result
          Severity: Minor
          Found in src/FormulaParser.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 convert has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function convert($token)
              {
                  if (Token::isString($token)) {
                      return $this->convertString($token);
                  } elseif (is_numeric($token)) {
          Severity: Minor
          Found in src/FormulaParser.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

          Consider simplifying this complex logical expression.
          Open

                  if ($this->isReference($token)
                      || $this->isExternalReference($token)
                      || $this->isAnyRange($token)
                      || $this->isNumber($token)
                      || Token::isString($token)
          Severity: Major
          Found in src/FormulaParser.php - About 40 mins to fix

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

                protected function fact()
                {
                    if ($this->currentToken == Token::TOKEN_OPEN) {
                        $this->advance(); // eat the "("
            
            
            Severity: Minor
            Found in src/FormulaParser.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 '';
            Severity: Major
            Found in src/FormulaParser.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return $result;
              Severity: Major
              Found in src/FormulaParser.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return $this->convertRange3d($token);
                Severity: Major
                Found in src/FormulaParser.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return pack("C", Ptg::get($token));
                  Severity: Major
                  Found in src/FormulaParser.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return $this->convertRange2d($token);
                    Severity: Major
                    Found in src/FormulaParser.php - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status