mossadal/math-parser

View on GitHub
src/MathParser/Interpreting/LaTeXPrinter.php

Summary

Maintainability
C
1 day
Test Coverage

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 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

    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

      Avoid too many return statements within this method.
      Open

              return "\\$functionName($operand)";
      Severity: Major
      Found in src/MathParser/Interpreting/LaTeXPrinter.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return '\frac{' . $left->accept($this) . '}{' . $right->accept($this) . '}';
        Severity: Major
        Found in src/MathParser/Interpreting/LaTeXPrinter.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

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

            Avoid too many return statements within this method.
            Open

                            return $this->visitFactorialNode($node);
            Severity: Major
            Found in src/MathParser/Interpreting/LaTeXPrinter.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                                  return "$leftValue$operator$rightValue";
              Severity: Major
              Found in src/MathParser/Interpreting/LaTeXPrinter.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return "($text)";
                Severity: Major
                Found in src/MathParser/Interpreting/LaTeXPrinter.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return '\infty{}';
                  Severity: Major
                  Found in src/MathParser/Interpreting/LaTeXPrinter.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return "$prepend$text";
                    Severity: Major
                    Found in src/MathParser/Interpreting/LaTeXPrinter.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                          return '{' . $text . '}';
                      Severity: Major
                      Found in src/MathParser/Interpreting/LaTeXPrinter.php - About 30 mins to fix

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

                            private function visitFactorialNode(FunctionNode $node)
                            {
                                $functionName = $node->getName();
                                $op = $node->getOperand();
                                $operand = $op->accept($this);
                        Severity: Minor
                        Found in src/MathParser/Interpreting/LaTeXPrinter.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