PHPOffice/PHPPresentation

View on GitHub

Showing 325 of 325 total issues

Avoid deeply nested control flow statements.
Open

                                        if ($element->hasHyperlink()) {
                                            // Write relationship for hyperlink
                                            $hyperlink = $element->getHyperlink();
                                            $hyperlink->relationId = 'rId' . $relId;

Severity: Major
Found in src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php - About 45 mins to fix

    Function writeTypeBar3D has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function writeTypeBar3D(XMLWriter $objWriter, Bar3D $subject, bool $includeSheet = false): void
        {
            // c:bar3DChart
            $objWriter->startElement('c:bar3DChart');
    
    
    Severity: Minor
    Found in src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php - About 45 mins 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

    Avoid deeply nested control flow statements.
    Open

                                        if ($element instanceof Run || $element instanceof TextElement) {
                                            if ($element->hasHyperlink()) {
                                                // Write relationship for hyperlink
                                                $hyperlink = $element->getHyperlink();
                                                $hyperlink->relationId = 'rId' . $relId;
    Severity: Major
    Found in src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php - About 45 mins to fix

      Function render has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function render(): ZipInterface
          {
              foreach ($this->oPresentation->getAllSlides() as $idx => $oSlide) {
                  $this->oZip->addFromString('ppt/slides/_rels/slide' . ($idx + 1) . '.xml.rels', $this->writeSlideRelationships($oSlide));
                  $this->oZip->addFromString('ppt/slides/slide' . ($idx + 1) . '.xml', $this->writeSlide($oSlide));
      Severity: Minor
      Found in src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php - About 45 mins 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

      Avoid deeply nested control flow statements.
      Open

                                  if (isset($clientTextbox['text' . $inc]['bulletChar'])) {
                                      $arrayReturn['shape']->getActiveParagraph()->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET);
                                      $arrayReturn['shape']->getActiveParagraph()->getBulletStyle()->setBulletChar($clientTextbox['text' . $inc]['bulletChar']);
                                  }
      Severity: Major
      Found in src/PhpPresentation/Reader/PowerPoint97.php - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                    if (isset($clientTextbox['text' . $inc]['leftMargin'])) {
                                        if ($lastMarginLeft > $clientTextbox['text' . $inc]['leftMargin']) {
                                            --$lastLevel;
                                        }
                                        if ($lastMarginLeft < $clientTextbox['text' . $inc]['leftMargin']) {
        Severity: Major
        Found in src/PhpPresentation/Reader/PowerPoint97.php - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                      if (!empty($clientTextbox['hyperlink'])) {
                                          foreach ($clientTextbox['hyperlink'] as $itmHyperlink) {
                                              if ($itmHyperlink['start'] == $start && ($itmHyperlink['end'] - $itmHyperlink['start']) == (float) $clientTextbox['part' . $inc]['partLength']) {
                                                  $sText = $this->arrayHyperlinks[$itmHyperlink['id']]['text'];
                                                  $sHyperlinkURL = $this->arrayHyperlinks[$itmHyperlink['id']]['url'];
          Severity: Major
          Found in src/PhpPresentation/Reader/PowerPoint97.php - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                                if ($this->currentNote > 0 && isset($arrayIdxSlide[$this->currentNote])) {
                                                    $oSlide = $this->oPhpPresentation->getSlide($arrayIdxSlide[$this->currentNote]);
                                                    if (0 == count($oSlide->getNote()->getShapeCollection())) {
                                                        $oSlide->getNote()->addShape($fileBlock['shape']);
                                                    }
            Severity: Major
            Found in src/PhpPresentation/Reader/PowerPoint97.php - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                          if (isset($clientTextbox['text' . $inc]['indent'])) {
                                              $indent = $clientTextbox['text' . $inc]['indent'];
                                          }
              Severity: Major
              Found in src/PhpPresentation/Reader/PowerPoint97.php - About 45 mins to fix

                Function readRecordOfficeArtClientData has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function readRecordOfficeArtClientData(string $stream, int $pos): array
                    {
                        $arrayReturn = [
                            'length' => 0,
                        ];
                Severity: Minor
                Found in src/PhpPresentation/Reader/PowerPoint97.php - About 45 mins 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

                Avoid deeply nested control flow statements.
                Open

                                            if ($shadowOffsetX > 0 && $shadowOffsetX == $shadowOffsetY) {
                                                $arrayReturn['shape']->getShadow()->setDistance($shadowOffsetX)->setDirection(45);
                                            }
                Severity: Major
                Found in src/PhpPresentation/Reader/PowerPoint97.php - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                              if ('..' == $partPath) {
                                                  unset($pathImage[$key - 1], $pathImage[$key]);
                                              }
                  Severity: Major
                  Found in src/PhpPresentation/Reader/PowerPoint2007.php - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if (!$image) {
                                                return;
                                            }
                    Severity: Major
                    Found in src/PhpPresentation/Reader/PowerPoint2007.php - About 45 mins to fix

                      Function loadPicturesStream has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function loadPicturesStream(): void
                          {
                              $stream = $this->streamPictures;
                      
                              $pos = 0;
                      Severity: Minor
                      Found in src/PhpPresentation/Reader/PowerPoint97.php - About 45 mins 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 writeRelationship has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          protected function writeRelationship(XMLWriter $objWriter, int $pId, string $pType, string $pTarget, string $pTargetMode = ''): void
                      Severity: Minor
                      Found in src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php - About 35 mins to fix

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

                                        if ($oElementColor instanceof DOMElement) {
                                            // Color
                                            $oColor = new SchemeColor();
                                            $oColor->setValue($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null);
                                            // Background
                        Severity: Minor
                        Found in src/PhpPresentation/Reader/PowerPoint2007.php and 1 other location - About 35 mins to fix
                        src/PhpPresentation/Reader/PowerPoint2007.php on lines 445..455

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

                        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

                                        if ($oElementColor instanceof DOMElement) {
                                            // Color
                                            $oColor = new Color();
                                            $oColor->setRGB($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null);
                                            // Background
                        Severity: Minor
                        Found in src/PhpPresentation/Reader/PowerPoint2007.php and 1 other location - About 35 mins to fix
                        src/PhpPresentation/Reader/PowerPoint2007.php on lines 457..467

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

                        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

                        Function writeSpreadsheet has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected function writeSpreadsheet(PhpPresentation $presentation, Chart $chart, string $tempName): string
                            {
                                // Create new spreadsheet
                                $spreadsheet = new Spreadsheet();
                        
                        
                        Severity: Minor
                        Found in src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php - About 35 mins 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 render has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function render(): ZipInterface
                            {
                                $arrMedia = [];
                                for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) {
                                    $shape = $this->getDrawingHashTable()->getByIndex($i);
                        Severity: Minor
                        Found in src/PhpPresentation/Writer/ODPresentation/Pictures.php - About 35 mins 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 absoluteZipPath has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected function absoluteZipPath(string $path): string
                            {
                                $path = str_replace([
                                    '/',
                                    '\\',
                        Severity: Minor
                        Found in src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php - About 35 mins 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

                        Severity
                        Category
                        Status
                        Source
                        Language