mossadal/math-parser

View on GitHub

Showing 178 of 188 total issues

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

    public function visitExpressionNode(ExpressionNode $node)
    {

        $operator = $node->getOperator();
        $left = $node->getLeft();
Severity: Minor
Found in src/MathParser/Interpreting/LaTeXPrinter.php - About 1 hr to fix

    Function visitFunctionNode has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public function visitFunctionNode(FunctionNode $node)
        {
            $inner = $node->getOperand()->accept($this);
            $arg = $node->getOperand();
    
    
    Severity: Minor
    Found in src/MathParser/Interpreting/Differentiator.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 ifactor has 35 lines of code (exceeds 25 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

      Method visitExpressionNode has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

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

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

          Function numericExponent has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              private function numericExponent($leftOperand, $rightOperand)
              {
                  // 0^0 throws an exception
                  if ($this->isNumeric($leftOperand) && $this->isNumeric($rightOperand)) {
                      if ($leftOperand->getValue() == 0 && $rightOperand->getValue() == 0)

          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 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function __construct($left, $operator = null, $right = null)
              {
                  $this->left = $this->sanitize($left);
                  $this->operator = $operator;
                  $this->right = $this->sanitize($right);
          Severity: Minor
          Found in src/MathParser/Parsing/Nodes/ExpressionNode.php - About 1 hr to fix

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

                public static function fromFloat($float, $tolerance=1e-7)
                {
                    if (is_string($float) && preg_match('~^\-?\d+([,|.]\d+)?$~', $float)) {
                        $float = floatval(str_replace(',','.',$float));
                    }
            Severity: Minor
            Found in src/MathParser/Extensions/Rational.php - About 1 hr to fix

              Method parenthesize has 30 lines of code (exceeds 25 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 1 hr to fix

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

                    private function rpow($a, $b)
                    {
                        if ($b->getDenominator() == 1) {
                            $n = $b->getNumerator();
                            if ($n >= 0) {
                Severity: Minor
                Found in src/MathParser/Interpreting/RationalEvaluator.php - About 1 hr to fix

                  Method handleExpression has 29 lines of code (exceeds 25 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

                    Method visitExpressionNode has 28 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/Evaluator.php - About 1 hr to fix

                      Method visitExpressionNode has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

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

                        Method factory has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public static function factory(Token $token)
                            {
                                switch ($token->getType()) {
                                    case TokenType::PosInt:
                                    case TokenType::Integer:
                        Severity: Minor
                        Found in src/MathParser/Parsing/Nodes/Node.php - About 1 hr to fix

                          Method rationalFactory has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function rationalFactory(Token $token)
                              {
                                  switch ($token->getType()) {
                                      case TokenType::PosInt:
                                      case TokenType::Integer:
                          Severity: Minor
                          Found in src/MathParser/Parsing/Nodes/Node.php - About 1 hr to fix

                            Method canFactorsInImplicitMultiplication has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public static function canFactorsInImplicitMultiplication($token1, $token2)
                                {
                                    if ($token1 === null || $token2 === null) return false;
                            
                                    $check1 = (
                            Severity: Minor
                            Found in src/MathParser/Lexing/Token.php - About 1 hr to fix

                              Function visitExpressionNode has a Cognitive Complexity of 9 (exceeds 5 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 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 parse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public static function parse($value, $normalize=true)
                                  {
                                      if ($value === '') return null;
                                      if ($value === 'NAN') return new Rational(NAN, 1);
                                      if ($value === 'INF') return new Rational(INF, 1);
                              Severity: Minor
                              Found in src/MathParser/Extensions/Rational.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 numericFactors has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  protected function numericFactors($leftOperand, $rightOperand)
                                  {
                                      if ($this->isNumeric($rightOperand) && $rightOperand->getValue() == 0) {
                                          throw new DivisionByZeroException();
                                      }
                              Severity: Minor
                              Found in src/MathParser/Parsing/Nodes/Factories/DivisionNodeFactory.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

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

                                  private function rpow($a, $b)
                                  {
                                      if ($b->getDenominator() == 1) {
                                          $n = $b->getNumerator();
                                          if ($n >= 0) {
                              Severity: Minor
                              Found in src/MathParser/Interpreting/RationalEvaluator.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

                              Severity
                              Category
                              Status
                              Source
                              Language