Showing 58 of 58 total issues
Consider simplifying this complex logical expression. Open
if (($red < 0 || $red > 255)
|| ($green < 0 || $green > 255)
|| ($blue < 0 || $blue > 255)
) {
throw new \Exception("Color component outside range: 0 <= color <= 255");
Method getData
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function getData($x, $y, $rowTop, $colLeft, $activePane)
Method writeUrl
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function writeUrl($row, $col, $url, $label = '', $format = null)
Method setValidation
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function setValidation($row1, $col1, $row2, $col2, $validator)
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$rowFrom = 0,
$colFrom = 0,
$rowTo = null,
$colTo = null,
$normalize = true
Function calcSize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function calcSize($list)
{
$iSBcnt = 0;
$iBBcnt = 0;
foreach ($list as $item) {
- 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 fact
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function fact()
{
if ($this->currentToken == Token::TOKEN_OPEN) {
$this->advance(); // eat the "("
- 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
Avoid too many return
statements within this method. Open
return '';
Avoid too many return
statements within this method. Open
return $result;
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function printRepeatRows($firstRow, $lastRow = null)
{
if (!isset($lastRow)) {
$lastRow = $firstRow;
}
- 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 90.
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
Avoid too many return
statements within this method. Open
return $this->convertRange3d($token);
Avoid too many return
statements within this method. Open
return pack("C", Ptg::get($token));
Avoid too many return
statements within this method. Open
return $this->convertRange2d($token);
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function printRepeatColumns($firstCol, $lastCol = null)
{
if (!isset($lastCol)) {
$lastCol = $firstCol;
}
- 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 90.
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
Avoid too many return
statements within this method. Open
return null;
Function storeAllNumFormats
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function storeAllNumFormats()
{
$map = array();
$index = 164;
- 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 calculateActivePane
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function calculateActivePane($x, $y)
{
if ($x != 0 && $y != 0) {
return 0; // Bottom right
} elseif ($x != 0 && $y == 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 positionImage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function positionImage($colStart, $rowStart, $x1, $y1, $width, $height)
{
// Initialise end cell to the same as the start cell
$colEnd = $colStart; // Col containing lower right corner of object
$rowEnd = $rowStart; // Row containing bottom right corner of object
- 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"