Showing 15,735 of 15,735 total issues
Avoid using undefined variables such as '$x' which will lead to PHP notices. Open
'transform-origin' => [$x, $y],
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$y' which will lead to PHP notices. Open
'transform-origin' => [$x, $y],
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
The class Document has 47 public methods and attributes. Consider reducing the number of public items to less than 45. Open
class Document
{
/**
* Actual id auto incremented.
*
- Read upRead up
- Exclude checks
ExcessivePublicCount
Since: 0.1
A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.
Example
public class Foo {
public $value;
public $something;
public $var;
// [... more more public attributes ...]
public function doWork() {}
public function doMoreWork() {}
public function doWorkAgain() {}
// [... more more public methods ...]
}
Source https://phpmd.org/rules/codesize.html#excessivepubliccount
The class Box has 58 public methods and attributes. Consider reducing the number of public items to less than 45. Open
class Box extends \YetiForcePDF\Base
{
/**
* Id of this box (should be cloned to track inline wrapped elements).
*
- Read upRead up
- Exclude checks
ExcessivePublicCount
Since: 0.1
A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.
Example
public class Foo {
public $value;
public $something;
public $var;
// [... more more public attributes ...]
public function doWork() {}
public function doMoreWork() {}
public function doWorkAgain() {}
// [... more more public methods ...]
}
Source https://phpmd.org/rules/codesize.html#excessivepubliccount
Method measureOffset
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function measureOffset(bool $afterPageDividing = false)
{
if (\YetiForcePDF\Page::CUT_BELOW === $this->wasCut()) {
return $this;
}
Method loadImage
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function loadImage(string $fileName)
{
if ('data:image' === substr($fileName, 0, 10)) {
$this->imageData = $this->convertToJpg($fileName);
} elseif (filter_var($fileName, FILTER_VALIDATE_URL)) {
Method addPage
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addPage(string $format = '', string $orientation = '', Page $page = null, Page $after = null): Page
{
if (null === $page) {
$page = (new Page())->setDocument($this)->init();
}
Function renderResources
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function renderResources(): string
{
$rendered = [
' /Resources <<',
];
- 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 mergeLineGroups
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function mergeLineGroups(array $lineGroups)
{
$lines = [];
foreach ($lineGroups as $lines) {
if (!empty($lines)) {
- 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 getColumns
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getColumns()
{
$columns = [];
foreach ($this->getChildren() as $rowGroup) {
foreach ($rowGroup->getChildren() as $row) {
- 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 loadImage
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function loadImage(string $fileName)
{
if ('data:image' === substr($fileName, 0, 10)) {
$this->imageData = $this->convertToJpg($fileName);
} elseif (filter_var($fileName, FILTER_VALIDATE_URL)) {
- 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 getStyleWidth
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getStyleWidth()
{
if (!$this->getBox()->isForMeasurement() && !$this->getBox()) {
return '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 divideLines
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function divideLines()
{
$this->mergeLineGroups($this->groupLines());
foreach ($this->getChildren() as $child) {
if ($child instanceof LineBox) {
- 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 addChild
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function addChild(self $child, self $after = null): self
{
$afterIndex = \count($this->children);
if ($after) {
foreach ($this->children as $afterIndex => $childObject) {
- 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 getOuterHeight
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getOuterHeight()
{
$box = $this->getBox();
if (!$box->isForMeasurement() && !$this->getBox()->getStyle()->haveSpacing()) {
return '0';
Method parseFont
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function parseFont(array $rulesParsed)
{
$finalRules = [];
foreach ($rulesParsed as $ruleName => $ruleValue) {
if ('font' === substr($ruleName, 0, 4)) {
Method clearMiddleInline
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function clearMiddleInline()
{
$box = $this->getBox();
$leftSpace = $this->getFullLeftSpace();
$dimensions = $box->getDimensions();
Similar blocks of code found in 2 locations. Consider refactoring. Open
$cellBorders = [
Math::max($cellBorders[0], $rowStyle->getRules('border-top-width')),
Math::max($cellBorders[1], $rowStyle->getRules('border-right-width')),
Math::max($cellBorders[2], $rowStyle->getRules('border-bottom-width')),
Math::max($cellBorders[3], $rowStyle->getRules('border-left-width')),
- 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 100.
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
$cellBorders = [
Math::max($cellBorders[0], $cellStyle->getRules('border-top-width')),
Math::max($cellBorders[1], $cellStyle->getRules('border-right-width')),
Math::max($cellBorders[2], $cellStyle->getRules('border-bottom-width')),
Math::max($cellBorders[3], $cellStyle->getRules('border-left-width')),
- 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 100.
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 4 locations. Consider refactoring. Open
protected function threeValues(array $ruleNames, array $numberValues)
{
$normalized = [];
$normalized[$ruleNames[0]] = $numberValues[0];
$normalized[$ruleNames[1]] = $numberValues[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 99.
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