YetiForceCompany/YetiForcePDF

View on GitHub

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],

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],

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.
     *
Severity: Minor
Found in lib/Document.php by phpmd

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).
     *
Severity: Minor
Found in lib/Layout/Box.php by phpmd

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;
        }
Severity: Minor
Found in lib/Layout/BlockBox.php - About 1 hr to fix

    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)) {
    Severity: Minor
    Found in lib/Objects/ImageStream.php - About 1 hr to fix

      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();
              }
      Severity: Minor
      Found in lib/Document.php - About 1 hr to fix

        Function renderResources has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function renderResources(): string
            {
                $rendered = [
                    '  /Resources <<',
                ];
        Severity: Minor
        Found in lib/Page.php - About 1 hr to fix

        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)) {
        Severity: Minor
        Found in lib/Layout/BlockBox.php - About 1 hr to fix

        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) {
        Severity: Minor
        Found in lib/Layout/TableBox.php - About 1 hr to fix

        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)) {
        Severity: Minor
        Found in lib/Objects/ImageStream.php - About 1 hr to fix

        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';
                }
        Severity: Minor
        Found in lib/Layout/Dimensions/BoxDimensions.php - About 1 hr to fix

        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) {
        Severity: Minor
        Found in lib/Layout/BlockBox.php - About 1 hr to fix

        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) {
        Severity: Minor
        Found in lib/Objects/PdfObject.php - About 1 hr to fix

        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';
        Severity: Minor
        Found in lib/Layout/Dimensions/BoxDimensions.php - About 1 hr to fix

          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)) {
          Severity: Minor
          Found in lib/Style/Style.php - About 1 hr to fix

            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();
            Severity: Minor
            Found in lib/Style/Style.php - About 1 hr to fix

              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')),
              Severity: Minor
              Found in lib/Style/Style.php and 1 other location - About 1 hr to fix
              lib/Style/Style.php on lines 1530..1535

              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

              Further Reading

              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')),
              Severity: Minor
              Found in lib/Style/Style.php and 1 other location - About 1 hr to fix
              lib/Style/Style.php on lines 1522..1527

              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

              Further Reading

              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];
              Severity: Major
              Found in lib/Style/Normalizer/Normalizer.php and 3 other locations - About 55 mins to fix
              lib/Style/Normalizer/Normalizer.php on lines 184..192
              lib/Style/Normalizer/Normalizer.php on lines 202..210
              lib/Style/Normalizer/Normalizer.php on lines 238..246

              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

              Further Reading

              Severity
              Category
              Status
              Source
              Language