File GTextTableCell.php
has 474 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* JPGraph v4.0.3
*/
Function Stroke
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
public function Stroke($aImg, $aX, $aY, $aWidth, $aHeight)
{
// If this is a merged cell we only stroke if it is the parent cell.
// The parent cell holds the merged cell block
if ($this->iMerged && ($this->iRow != $this->iPRow || $this->iCol != $this->iPCol)) {
- 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 Stroke
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function Stroke($aImg, $aX, $aY, $aWidth, $aHeight)
{
// If this is a merged cell we only stroke if it is the parent cell.
// The parent cell holds the merged cell block
if ($this->iMerged && ($this->iRow != $this->iPRow || $this->iCol != $this->iPCol)) {
The class GTextTableCell has an overall complexity of 126 which is very high. The configured complexity threshold is 50. Open
class GTextTableCell
{
public $iColSpan = 1;
public $iRowSpan = 1;
public $iMarginLeft = 5;
- Exclude checks
GTextTableCell
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class GTextTableCell
{
public $iColSpan = 1;
public $iRowSpan = 1;
public $iMarginLeft = 5;
Function AdjustMarginsForGrid
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function AdjustMarginsForGrid()
{
if ($this->iCol > 0) {
switch ($this->iGridStyle[0]) {
case TGRID_SINGLE:
- 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 StrokeVGrid
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function StrokeVGrid($aImg, $aX, $aY, $aWidth, $aHeight, $aDir = 1)
{
// Left or right grid line
// For the right we increase the X-pos and for the right we decrease it. This is
// determined by the direction argument.
- 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 StrokeHGrid
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function StrokeHGrid($aImg, $aX, $aY, $aWidth, $aHeight, $aDir = 1)
{
// Top or bottom grid line
// For the left we increase the X-pos and for the right we decrease it. This is
// determined by the direction argument.
- 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 AdjustMarginsForGrid
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function AdjustMarginsForGrid()
{
if ($this->iCol > 0) {
switch ($this->iGridStyle[0]) {
case TGRID_SINGLE:
The class GTextTableCell has 30 fields. Consider redesigning GTextTableCell to keep the number of fields under 15. Open
class GTextTableCell
{
public $iColSpan = 1;
public $iRowSpan = 1;
public $iMarginLeft = 5;
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
Method StrokeVGrid
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function StrokeVGrid($aImg, $aX, $aY, $aWidth, $aHeight, $aDir = 1)
{
// Left or right grid line
// For the right we increase the X-pos and for the right we decrease it. This is
// determined by the direction argument.
Method StrokeHGrid
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function StrokeHGrid($aImg, $aX, $aY, $aWidth, $aHeight, $aDir = 1)
{
// Top or bottom grid line
// For the left we increase the X-pos and for the right we decrease it. This is
// determined by the direction argument.
Function GetWidth
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function GetWidth($aImg)
{
if ($this->iIcon !== null) {
if ($this->iIconConstrain[0] == TIMG_WIDTH) {
$this->iIcon->SetScale(1);
- 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 StrokeHGrid
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function StrokeHGrid($aImg, $aX, $aY, $aWidth, $aHeight, $aDir = 1)
Method StrokeVGrid
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function StrokeVGrid($aImg, $aX, $aY, $aWidth, $aHeight, $aDir = 1)
Method Stroke
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function Stroke($aImg, $aX, $aY, $aWidth, $aHeight)
Function GetHeight
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function GetHeight($aImg)
{
if ($this->iIcon !== null) {
if ($this->iIconConstrain[0] == TIMG_WIDTH) {
$this->iIcon->SetScale(1);
- 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
The method Stroke() has 126 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function Stroke($aImg, $aX, $aY, $aWidth, $aHeight)
{
// If this is a merged cell we only stroke if it is the parent cell.
// The parent cell holds the merged cell block
if ($this->iMerged && ($this->iRow != $this->iPRow || $this->iCol != $this->iPCol)) {
- Exclude checks
The method AdjustMarginsForGrid() has an NPath complexity of 256. The configured NPath complexity threshold is 200. Open
public function AdjustMarginsForGrid()
{
if ($this->iCol > 0) {
switch ($this->iGridStyle[0]) {
case TGRID_SINGLE:
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method Stroke() has an NPath complexity of 234000. The configured NPath complexity threshold is 200. Open
public function Stroke($aImg, $aX, $aY, $aWidth, $aHeight)
{
// If this is a merged cell we only stroke if it is the parent cell.
// The parent cell holds the merged cell block
if ($this->iMerged && ($this->iRow != $this->iPRow || $this->iCol != $this->iPCol)) {
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method AdjustMarginsForGrid() has a Cyclomatic Complexity of 17. The configured cyclomatic complexity threshold is 10. Open
public function AdjustMarginsForGrid()
{
if ($this->iCol > 0) {
switch ($this->iGridStyle[0]) {
case TGRID_SINGLE:
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method StrokeVGrid() has a Cyclomatic Complexity of 16. The configured cyclomatic complexity threshold is 10. Open
public function StrokeVGrid($aImg, $aX, $aY, $aWidth, $aHeight, $aDir = 1)
{
// Left or right grid line
// For the right we increase the X-pos and for the right we decrease it. This is
// determined by the direction argument.
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method StrokeHGrid() has a Cyclomatic Complexity of 16. The configured cyclomatic complexity threshold is 10. Open
public function StrokeHGrid($aImg, $aX, $aY, $aWidth, $aHeight, $aDir = 1)
{
// Top or bottom grid line
// For the left we increase the X-pos and for the right we decrease it. This is
// determined by the direction argument.
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method Stroke() has a Cyclomatic Complexity of 29. The configured cyclomatic complexity threshold is 10. Open
public function Stroke($aImg, $aX, $aY, $aWidth, $aHeight)
{
// If this is a merged cell we only stroke if it is the parent cell.
// The parent cell holds the merged cell block
if ($this->iMerged && ($this->iRow != $this->iPRow || $this->iCol != $this->iPCol)) {
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method SetMerged has a boolean flag argument $aFlg, which is a certain sign of a Single Responsibility Principle violation. Open
public function SetMerged($aPRow, $aPCol, $aFlg = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Avoid using static access to class '\Amenadiel\JpGraph\Util\JpGraphError' in method 'Stroke'. Open
Util\JpGraphError::RaiseL(27012, $this->iVertAlign);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Amenadiel\JpGraph\Util\JpGraphError' in method 'Stroke'. Open
Util\JpGraphError::RaiseL(27012, $this->iVertAlign);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Amenadiel\JpGraph\Util\JpGraphError' in method 'Stroke'. Open
Util\JpGraphError::RaiseL(27012, $this->iHorAlign);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method GetWidth uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$iwidth = 0;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method GetHeight uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$pheight = $this->iTable->iCells[$this->iPRow][$this->iPCol]->iVal->GetHeight($aImg) + 1;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\Amenadiel\JpGraph\Util\JpGraphError' in method 'SetAlign'. Open
Util\JpGraphError::RaiseL(27011, $aHorAlign, $aVertAlign);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method GetWidth uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$pwidth = $this->iTable->iCells[$this->iPRow][$this->iPCol]->iVal->GetWidth($aImg) + 2;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\Amenadiel\JpGraph\Util\JpGraphError' in method 'Stroke'. Open
Util\JpGraphError::RaiseL(27012, $this->iHorAlign);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method GetHeight uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$iheight = 0;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\Amenadiel\JpGraph\Util\JpGraphError' in method 'SetImageConstrain'. Open
Util\JpGraphError::RaiseL(27015);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($this->iIcon !== null) {
if ($this->iIconConstrain[0] == TIMG_WIDTH) {
$this->iIcon->SetScale(1);
$tmp = $this->iIcon->GetWidthHeight();
$this->iIcon->SetScale($this->iIconConstrain[1] / $tmp[0]);
- 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 178.
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
if ($this->iIcon !== null) {
if ($this->iIconConstrain[0] == TIMG_WIDTH) {
$this->iIcon->SetScale(1);
$tmp = $this->iIcon->GetWidthHeight();
$this->iIcon->SetScale($this->iIconConstrain[1] / $tmp[0]);
- 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 178.
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
public function SetGridStyle($aLeft, $aTop = null, $aBottom = null, $aRight = null)
{
if ($aLeft !== null) {
$this->iGridStyle[0] = $aLeft;
}
- 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 135.
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
public function SetGridColor($aLeft, $aTop = null, $aBottom = null, $aRight = null)
{
if ($aLeft !== null) {
$this->iGridColor[0] = $aLeft;
}
- 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 135.
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
if ($this->iRow + $this->iRowSpan - 1 < $this->iTable->iSize[0] - 1) {
switch ($this->iGridStyle[2]) {
case TGRID_SINGLE:
$wf = 1;
- 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 107.
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
if ($this->iCol + $this->iColSpan - 1 < $this->iTable->iSize[1] - 1) {
switch ($this->iGridStyle[3]) {
case TGRID_SINGLE:
$wf = 1;
- 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 107.
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 variables with short names like $x. Configured minimum length is 3. Open
$x = $aDir == 1 ? $aX : $aX + $aWidth - 1;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $y. Configured minimum length is 3. Open
$y = $aY + $this->iMarginTop;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $y. Configured minimum length is 3. Open
$y = $aDir == 1 ? $aY : $aY + $aHeight - 1;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $x. Configured minimum length is 3. Open
$x = $aX + $aWidth - 1;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $wf. Configured minimum length is 3. Open
$wf = 1;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $aX. Configured minimum length is 3. Open
public function StrokeHGrid($aImg, $aX, $aY, $aWidth, $aHeight, $aDir = 1)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $aY. Configured minimum length is 3. Open
public function StrokeVGrid($aImg, $aX, $aY, $aWidth, $aHeight, $aDir = 1)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $aY. Configured minimum length is 3. Open
public function Stroke($aImg, $aX, $aY, $aWidth, $aHeight)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $aY. Configured minimum length is 3. Open
public function StrokeHGrid($aImg, $aX, $aY, $aWidth, $aHeight, $aDir = 1)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $aF. Configured minimum length is 3. Open
public function SetNumberFormat($aF)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $y. Configured minimum length is 3. Open
$y = $aY + $aHeight - 1;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $aX. Configured minimum length is 3. Open
public function Stroke($aImg, $aX, $aY, $aWidth, $aHeight)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $x. Configured minimum length is 3. Open
$x = $aX + $this->iMarginLeft;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $aX. Configured minimum length is 3. Open
public function StrokeVGrid($aImg, $aX, $aY, $aWidth, $aHeight, $aDir = 1)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Method name "GTextTableCell::Set" is not in camel caps format Open
public function Set($aTxt)
- Exclude checks
Method name "GTextTableCell::SetImageConstrain" is not in camel caps format Open
public function SetImageConstrain($aType, $aVal)
- Exclude checks
Method name "GTextTableCell::SetMerged" is not in camel caps format Open
public function SetMerged($aPRow, $aPCol, $aFlg = true)
- Exclude checks
Method name "GTextTableCell::Init" is not in camel caps format Open
public function Init($aTable)
- Exclude checks
Method name "GTextTableCell::SetCSIMTarget" is not in camel caps format Open
public function SetCSIMTarget($aTarget, $aAlt = '', $aWinTarget = '')
- Exclude checks
Method name "GTextTableCell::GetCSIMArea" is not in camel caps format Open
public function GetCSIMArea()
- Exclude checks
Method name "GTextTableCell::SetGridColor" is not in camel caps format Open
public function SetGridColor($aLeft, $aTop = null, $aBottom = null, $aRight = null)
- Exclude checks
Method name "GTextTableCell::SetFontColor" is not in camel caps format Open
public function SetFontColor($aColor)
- Exclude checks
Method name "GTextTableCell::SetMargin" is not in camel caps format Open
public function SetMargin($aLeft, $aRight, $aTop, $aBottom)
- Exclude checks
Method name "GTextTableCell::SetImage" is not in camel caps format Open
public function SetImage($aFile, $aScale = 1.0, $aMix = 100)
- Exclude checks
Method name "GTextTableCell::SetNumberFormat" is not in camel caps format Open
public function SetNumberFormat($aF)
- Exclude checks
Method name "GTextTableCell::SetRowColSpan" is not in camel caps format Open
public function SetRowColSpan($aRowSpan, $aColSpan)
- Exclude checks
Method name "GTextTableCell::SetImageFromString" is not in camel caps format Open
public function SetImageFromString($aStr, $aScale = 1.0, $aMix = 100)
- Exclude checks
Method name "GTextTableCell::IsMerged" is not in camel caps format Open
public function IsMerged()
- Exclude checks
Method name "GTextTableCell::SetGridStyle" is not in camel caps format Open
public function SetGridStyle($aLeft, $aTop = null, $aBottom = null, $aRight = null)
- Exclude checks
Method name "GTextTableCell::SetGridWeight" is not in camel caps format Open
public function SetGridWeight($aLeft = null, $aTop = null, $aBottom = null, $aRight = null)
- Exclude checks
Method name "GTextTableCell::GetWidth" is not in camel caps format Open
public function GetWidth($aImg)
- Exclude checks
Method name "GTextTableCell::SetFont" is not in camel caps format Open
public function SetFont($aFF, $aFS, $aFSize)
- Exclude checks
Method name "GTextTableCell::SetCountryFlag" is not in camel caps format Open
public function SetCountryFlag($aFlag, $aScale = 1.0, $aMix = 100, $aStdSize = 3)
- Exclude checks
Method name "GTextTableCell::SetFillColor" is not in camel caps format Open
public function SetFillColor($aColor)
- Exclude checks
Method name "GTextTableCell::GetHeight" is not in camel caps format Open
public function GetHeight($aImg)
- Exclude checks
Method name "GTextTableCell::SetAlign" is not in camel caps format Open
public function SetAlign($aHorAlign = 'left', $aVertAlign = 'bottom')
- Exclude checks
Method name "GTextTableCell::StrokeVGrid" is not in camel caps format Open
public function StrokeVGrid($aImg, $aX, $aY, $aWidth, $aHeight, $aDir = 1)
- Exclude checks
Method name "GTextTableCell::Stroke" is not in camel caps format Open
public function Stroke($aImg, $aX, $aY, $aWidth, $aHeight)
- Exclude checks
Method name "GTextTableCell::StrokeHGrid" is not in camel caps format Open
public function StrokeHGrid($aImg, $aX, $aY, $aWidth, $aHeight, $aDir = 1)
- Exclude checks
Method name "GTextTableCell::AdjustMarginsForGrid" is not in camel caps format Open
public function AdjustMarginsForGrid()
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
if ((($this->iRow > 0 && $idx == 1) || ($this->iRow + $this->iRowSpan - 1 < $this->iTable->iSize[0] - 1 && $idx == 2))
- Exclude checks
Line exceeds 120 characters; contains 172 characters Open
$coords = $aX . ',' . $aY . ',' . ($aX + $aWidth - 1) . ',' . $aY . ',' . ($aX + $aWidth - 1) . ',' . ($aY + $aHeight - 1) . ',' . $aX . ',' . ($aY + $aHeight - 1);
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
$x = $aX + $this->iMarginLeft + round(($aWidth - $this->iMarginLeft - $this->iMarginRight) / 2);
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
if ((($this->iCol > 0 && $idx == 0) || ($this->iCol + $this->iColSpan - 1 < $this->iTable->iSize[1] - 1 && $idx == 3))
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
$y = $aY + $this->iMarginTop + round(($aHeight - $this->iMarginTop - $this->iMarginBottom) / 2);
- Exclude checks