Showing 147 of 154 total issues
Method visitInfixExpressionNode
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitInfixExpressionNode(InfixExpressionNode $node)
{
$left = $node->getLeft();
$operator = $node->operator;
$right = $node->getRight();
Method ifactor
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function ifactor($n): array
{
// max_n = 2^31-1 = 2147483647
$d = 2;
Method factory
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function factory(Token $token): Node
{
return match ($token->type) {
// Operands
TokenType::NATURAL_NUMBER,
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);
Method parenthesize
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parenthesize(
?Node $node,
InfixExpressionNode $cutoff,
string $prepend = '',
bool $conservative = false
Method fromFloat
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function fromFloat(float|string $float, float $tolerance = 1e-7): Rational
{
if (is_string($float) && preg_match('~^-?\d+([,|.]\d+)?$~', $float)) {
$float = (float)str_replace(',', '.', $float);
}
Method parse
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function parse(string|Rational $value, bool $normalize = true): Rational
{
if ($value === '') {
throw new SyntaxErrorException();
}
Method compareTo
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function compareTo(Node $other): bool
{
if (!($other instanceof static)) {
return false;
}
Method rpow
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function rpow($a, $b)
{
if ($b->getDenominator() === 1) {
$n = $b->getNumerator();
if ($n >= 0) {
Function visitTernaryNode
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function visitTernaryNode(TernaryExpressionNode $node): float
{
/** @var InfixExpressionNode|BooleanNode $condition */
$condition = $node->getCondition();
- Read upRead up
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 complexity
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function complexity(): int
{
switch (\get_class($this)) {
case IntegerNode::class:
case VariableNode::class:
Function numericFactors
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function numericFactors(Node $leftOperand, Node $rightOperand): ?Node
{
if (
($this->isNumeric($leftOperand) && (float)$leftOperand->value === 0.0) ||
($this->isNumeric($rightOperand) && (float)$rightOperand->value === 0.0)
- Read upRead up
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 visitInfixExpressionNode
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function visitInfixExpressionNode(InfixExpressionNode $node): Node
{
$left = $node->getLeft();
$operator = $node->operator;
$right = $node->getRight();
- Read upRead up
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 isUnary
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function isUnary(Node $node, ?Node $lastNode): bool
{
if (!$node instanceof InfixExpressionNode) {
return false;
}
- Read upRead up
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(string|Rational $value, bool $normalize = true): Rational
{
if ($value === '') {
throw new SyntaxErrorException();
}
- Read upRead up
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 compareTo
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function compareTo(Node $other): bool
{
if (!($other instanceof static)) {
return false;
}
- Read upRead up
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 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();
- Read upRead up
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 populateNode
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function populateNode(AbstractOperatorNode $node): Node
{
if ($node instanceof FunctionNode) {
throw new DelimeterMismatchException($node->operator);
}
- Read upRead up
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 7 (exceeds 5 allowed). Consider refactoring. Open
private function rpow($a, $b)
{
if ($b->getDenominator() === 1) {
$n = $b->getNumerator();
if ($n >= 0) {
- Read upRead up
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 7 (exceeds 5 allowed). Consider refactoring. Open
protected function numericFactors(Node $leftOperand, Node $rightOperand): ?Node
{
if ($this->isNumeric($rightOperand) && (float)$rightOperand->value === 0.0) {
throw new DivisionByZeroException();
}
- Read upRead up
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"