YetiForceCompany/YetiForcePDF

View on GitHub

Showing 15,735 of 15,735 total issues

Function cloneAndDivideChildrenAfterY has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function cloneAndDivideChildrenAfterY(string $yPos, array $boxes = null)
    {
        if (null === $boxes) {
            $boxes = [];
            foreach ($this->getBox()->getChildren() as $child) {
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 addPage has a Cognitive Complexity of 12 (exceeds 5 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

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 measureOffset has a Cognitive Complexity of 12 (exceeds 5 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

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 getChildren has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function getChildren(bool $onlyRenderable = false, bool $onlyForMeasurment = false): array
    {
        if (!$onlyRenderable && !$onlyForMeasurment) {
            return $this->children;
        }
Severity: Minor
Found in lib/Layout/Box.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 addObject has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function addObject(PdfObject $object, $after = null): self
    {
        $afterIndex = \count($this->objects);
        if ($after) {
            foreach ($this->objects as $afterIndex => $obj) {
Severity: Minor
Found in lib/Document.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 getBoxesByTagName has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function getBoxesByTagName(string $tagName)
    {
        $boxes = [];
        $allChildren = [];
        $this->getAllChildren($allChildren);
Severity: Minor
Found in lib/Layout/ElementBox.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 getOuterWidth has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getOuterWidth()
    {
        $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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    <?php
    
    declare(strict_types=1);
    /**
     * MaxWidth class.
    Severity: Major
    Found in lib/Style/Normalizer/MaxWidth.php and 1 other location - About 1 hr to fix
    lib/Style/Normalizer/Width.php on lines 1..31

    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 108.

    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

    <?php
    
    declare(strict_types=1);
    /**
     * Width class.
    Severity: Major
    Found in lib/Style/Normalizer/Width.php and 1 other location - About 1 hr to fix
    lib/Style/Normalizer/MaxWidth.php on lines 1..31

    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 108.

    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

            foreach ($this->pixelColumns as $columnIndex => $columns) {
                $colDmns = $columns[0]->getDimensions();
                $colWidth = $colDmns->getInnerWidth();
                if (Math::comp($this->preferredWidths[$columnIndex], $colWidth) > 0) {
                    $pixelNeeded[$columnIndex] = Math::sub($this->preferredWidths[$columnIndex], $colWidth);
    Severity: Major
    Found in lib/Layout/TableBox.php and 1 other location - About 1 hr to fix
    lib/Layout/TableBox.php on lines 443..450

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            foreach ($this->autoColumns as $columnIndex => $columns) {
                $colDmns = $columns[0]->getDimensions();
                $colWidth = $colDmns->getInnerWidth();
                if (Math::comp($this->preferredWidths[$columnIndex], $colWidth) > 0) {
                    $autoNeeded[$columnIndex] = Math::sub($this->preferredWidths[$columnIndex], $colWidth);
    Severity: Major
    Found in lib/Layout/TableBox.php and 1 other location - About 1 hr to fix
    lib/Layout/TableBox.php on lines 451..458

    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

    Further Reading

    Method getMaxWidth has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getMaxWidth()
        {
            $box = $this->getBox();
            if (!$box->isForMeasurement()) {
                return '0';
    Severity: Minor
    Found in lib/Layout/Dimensions/BoxDimensions.php - About 1 hr to fix

      Method clearStyles has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function clearStyles()
          {
              $allNestedChildren = [];
              $maxLevel = '0';
              foreach ($this->getChildren() as $child) {
      Severity: Minor
      Found in lib/Layout/LineBox.php - About 1 hr to fix

        Method matchFont has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function matchFont(bool $custom = false)
            {
                if (!$custom) {
                    return static::$fontFiles[$this->family][$this->weight][$this->style];
                }
        Severity: Minor
        Found in lib/Objects/Font.php - About 1 hr to fix

          Function removeChild has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function removeChild(self $child)
              {
                  $oldChildren = $this->children; // copy children
                  $this->children = [];
                  foreach ($oldChildren as $currentChild) {
          Severity: Minor
          Found in lib/Layout/Box.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 normalize has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function normalize($ruleValue, string $ruleName = ''): array
              {
                  if (null !== $this->normalized) {
                      return $this->normalized;
                  }
          Severity: Minor
          Found in lib/Style/Normalizer/Border.php - About 1 hr to fix

            Method render has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function render(): string
                {
                    $xref = '';
                    $this->buffer = '';
            
            
            Severity: Minor
            Found in lib/Document.php - About 1 hr to fix

              Method setUpSizingTypes has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function setUpSizingTypes()
                  {
                      $columnSizingTypes = [];
                      // rowGroup -> row -> columns
                      $columns = $this->getFirstChild()->getFirstChild()->getChildren();
              Severity: Minor
              Found in lib/Layout/TableBox.php - About 1 hr to fix

                The class Style has 53 public methods and attributes. Consider reducing the number of public items to less than 45.
                Open

                class Style extends \YetiForcePDF\Base
                {
                    /**
                     * @var \YetiForcePDF\Document
                     */
                Severity: Minor
                Found in lib/Style/Style.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

                Avoid using undefined variables such as '$rules' which will lead to PHP notices.
                Open

                        unset($finalRules, $rules, $rulesParsed, $default, $inherited, $class, $inline, $inlineTemp);
                Severity: Minor
                Found in lib/Style/Style.php by phpmd

                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

                Severity
                Category
                Status
                Source
                Language