mossadal/math-parser

View on GitHub

Showing 178 of 188 total issues

Function shuntingYard has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    private function shuntingYard(array $tokens)
    {
        // Clear the oepratorStack
        $this->operatorStack = new Stack();

Severity: Minor
Found in src/MathParser/Parsing/Parser.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

Complex has 36 functions (exceeds 20 allowed). Consider refactoring.
Open

class Complex
{
    /**
     * float $x real part
     */
Severity: Minor
Found in src/MathParser/Extensions/Complex.php - About 4 hrs to fix

    Method visitFunctionNode has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function visitFunctionNode(FunctionNode $node)
        {
            $inner = $node->getOperand()->accept($this);
    
            switch ($node->getName()) {
    Severity: Major
    Found in src/MathParser/Interpreting/Evaluator.php - About 3 hrs to fix

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

          public static function parse($value)
          {
              if ($value instanceof Complex) return $value;
              if ($value instanceof Rational) return new Complex($value.p/$value.q, 0);
      
      
      Severity: Minor
      Found in src/MathParser/Extensions/Complex.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 parenthesize has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public function parenthesize(Node $node, ExpressionNode $cutoff, $prepend = '', $conservative = false)
          {
              $text = $node->accept($this);
      
              if ($node instanceof ExpressionNode) {
      Severity: Minor
      Found in src/MathParser/Interpreting/ASCIIPrinter.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 visitFunctionNode has 76 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function visitFunctionNode(FunctionNode $node)
          {
              $inner = $node->getOperand()->accept($this);
              $arg = $node->getOperand();
      
      
      Severity: Major
      Found in src/MathParser/Interpreting/Differentiator.php - About 3 hrs to fix

        File RationalEvaluator.php has 273 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /*
         * @author      Frank Wikström <frank@mossadal.se>
         * @copyright   2016 Frank Wikström
         * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
        Severity: Minor
        Found in src/MathParser/Interpreting/RationalEvaluator.php - About 2 hrs to fix

          File Complex.php has 271 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /*
           * @package     Complex
           * @author      Frank Wikström <frank@mossadal.se>
           * @copyright   2016 Frank Wikström
          Severity: Minor
          Found in src/MathParser/Extensions/Complex.php - About 2 hrs to fix

            Method visitFunctionNode has 62 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function visitFunctionNode(FunctionNode $node)
                {
                    $z = $node->getOperand()->accept($this);
                    $a = $z->r();
                    $b = $z->i();
            Severity: Major
            Found in src/MathParser/Interpreting/ComplexEvaluator.php - About 2 hrs to fix

              Function parenthesize has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function parenthesize(Node $node, ExpressionNode $cutoff, $prepend = '', $conservative = false)
                  {
                      $text = $node->accept($this);
              
                      if ($node instanceof ExpressionNode) {
              Severity: Minor
              Found in src/MathParser/Interpreting/LaTeXPrinter.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 shuntingYard has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function shuntingYard(array $tokens)
                  {
                      // Clear the oepratorStack
                      $this->operatorStack = new Stack();
              
              
              Severity: Major
              Found in src/MathParser/Parsing/Parser.php - About 2 hrs to fix

                Method parse has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function parse($value)
                    {
                        if ($value instanceof Complex) return $value;
                        if ($value instanceof Rational) return new Complex($value.p/$value.q, 0);
                
                
                Severity: Major
                Found in src/MathParser/Extensions/Complex.php - About 2 hrs to fix

                  Function ifactor has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function ifactor($n)
                      {
                  
                          // max_n = 2^31-1 = 2147483647
                          $d = 2;
                  Severity: Minor
                  Found in src/MathParser/Interpreting/RationalEvaluator.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 visitExpressionNode has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function visitExpressionNode(ExpressionNode $node)
                      {
                          $operator = $node->getOperator();
                  
                          $leftValue = $node->getLeft()->accept($this);
                  Severity: Minor
                  Found in src/MathParser/Interpreting/Differentiator.php - About 1 hr to fix

                    Method __construct has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function __construct()
                        {
                            $this->add(new TokenDefinition('/\d+[,\.]\d+(e[+-]?\d+)?/', TokenType::RealNumber));
                    
                            $this->add(new TokenDefinition('/\d+/', TokenType::PosInt));
                    Severity: Minor
                    Found in src/MathParser/Lexing/StdMathLexer.php - About 1 hr to fix

                      Method visitFunctionNode has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function visitFunctionNode(FunctionNode $node)
                          {
                              $inner = $node->getOperand()->accept($this);
                      
                              switch ($node->getName()) {
                      Severity: Minor
                      Found in src/MathParser/Interpreting/RationalEvaluator.php - About 1 hr to fix

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

                            public function __toString()
                            {
                                // TODO: use Number:: helper functions.
                        
                                $realAsRational = Rational::fromFloat($this->x);
                        Severity: Minor
                        Found in src/MathParser/Extensions/Complex.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 handleExpression has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected function handleExpression($node)
                            {
                                if ($node instanceof FunctionNode) throw new ParenthesisMismatchException($node->getOperator());
                                if ($node instanceof SubExpressionNode) throw new ParenthesisMismatchException($node->getOperator());
                        
                        
                        Severity: Minor
                        Found in src/MathParser/Parsing/Parser.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 __construct has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function __construct()
                            {
                                $this->add(new TokenDefinition('/\d+[,\.]\d+/', TokenType::RealNumber));
                                $this->add(new TokenDefinition('/\d+/', TokenType::PosInt));
                        
                        
                        Severity: Minor
                        Found in src/MathParser/Lexing/ComplexLexer.php - About 1 hr to fix

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

                              private function numericFactors($leftOperand, $rightOperand)
                              {
                                  if ($this->isNumeric($rightOperand)) {
                                      if ($rightOperand->getValue() == 0) return new IntegerNode(0);
                                      if ($rightOperand->getValue() == 1) return $leftOperand;

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language