Showing 188 of 188 total issues
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()) {
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);
- 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 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());
- 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 __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));
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;
- 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 visitExpressionNode
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitExpressionNode(ExpressionNode $node)
{
$operator = $node->getOperator();
$left = $node->getLeft();
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();
- 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 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;
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);
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);
Similar blocks of code found in 2 locations. Consider refactoring. Open
<?php
namespace MathParser;
/*
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 106.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
<?php
namespace MathParser;
use MathParser\Lexing\StdMathLexer;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 106.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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)
- 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 __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);
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));
}
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) {
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) {
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());
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);
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();