j84reginato/my-eval

View on GitHub
src/Solving/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,
        InfixExpressionNode $cutoff,
        string $prepend = '',
        bool $conservative = false
Severity: Minor
Found in src/Solving/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 visitInfixExpressionNode has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function visitInfixExpressionNode(InfixExpressionNode $node): string
    {
        $left     = $node->getLeft();
        $operator = $node->operator;
        $right    = $node->getRight();
Severity: Minor
Found in src/Solving/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): string
        {
            $functionName = $node->operator;
    
            $operand = $node->operand->accept($this);
    Severity: Minor
    Found in src/Solving/LaTeXPrinter.php - About 1 hr to fix

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

          public function visitInfixExpressionNode(InfixExpressionNode $node): string
          {
              $left     = $node->getLeft();
              $operator = $node->operator;
              $right    = $node->getRight();
      Severity: Minor
      Found in src/Solving/LaTeXPrinter.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 "$leftValue$operator$rightValue";
      Severity: Major
      Found in src/Solving/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/Solving/LaTeXPrinter.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

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

            Avoid too many return statements within this method.
            Open

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

              Avoid too many return statements within this method.
              Open

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

                Avoid too many return statements within this method.
                Open

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

                  Avoid too many return statements within this method.
                  Open

                                  return $result;
                  Severity: Major
                  Found in src/Solving/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/Solving/LaTeXPrinter.php - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status