PHPOffice/PHPPresentation

View on GitHub

Showing 325 of 325 total issues

File PptTheme.php has 441 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * This file is part of PHPPresentation - A pure PHP library for reading and writing
 * presentations documents.
 *
Severity: Minor
Found in src/PhpPresentation/Writer/PowerPoint2007/PptTheme.php - About 6 hrs to fix

    Function writeShapeText has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function writeShapeText(XMLWriter $objWriter, RichText $shape, int $shapeId): void
        {
            // p:sp
            $objWriter->startElement('p:sp');
            // p:sp\p:nvSpPr
    Severity: Minor
    Found in src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php - About 6 hrs 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 writeTableStyle has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function writeTableStyle(XMLWriter $objWriter, Table $shape): void
        {
            foreach ($shape->getRows() as $keyRow => $shapeRow) {
                // style:style
                $objWriter->startElement('style:style');
    Severity: Minor
    Found in src/PhpPresentation/Writer/ODPresentation/Content.php - About 6 hrs 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

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

                    foreach ($richtexts as $richtext) {
                        ++$richtextId;
                        if ($richtext instanceof TextElement) {
                            // text:span
                            $objWriter->startElement('text:span');
    Severity: Major
    Found in src/PhpPresentation/Writer/ODPresentation/Content.php and 1 other location - About 6 hrs to fix
    src/PhpPresentation/Writer/ODPresentation/Content.php on lines 536..563

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

    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

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

                    foreach ($richtexts as $richtext) {
                        ++$richtextId;
                        if ($richtext instanceof TextElement) {
                            // text:span
                            $objWriter->startElement('text:span');
    Severity: Major
    Found in src/PhpPresentation/Writer/ODPresentation/Content.php and 1 other location - About 6 hrs to fix
    src/PhpPresentation/Writer/ODPresentation/Content.php on lines 600..627

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

    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 writeSlideAnimations has 146 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function writeSlideAnimations(XMLWriter $objWriter, Slide $oSlide): void
        {
            $arrayAnimations = $oSlide->getAnimations();
            if (empty($arrayAnimations)) {
                return;
    Severity: Major
    Found in src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php - About 5 hrs to fix

      Function loadSlide has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function loadSlide(string $sPart, string $baseFile): void
          {
              $xmlReader = new XMLReader();
              // @phpstan-ignore-next-line
              if ($xmlReader->getDomFromString($sPart)) {
      Severity: Minor
      Found in src/PhpPresentation/Reader/PowerPoint2007.php - About 5 hrs 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 render has 138 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function render(): ZipInterface
          {
              // Create XML writer
              $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
      
      
      Severity: Major
      Found in src/PhpPresentation/Writer/PowerPoint2007/PptPresentation.php - About 5 hrs to fix

        Method writeShapeTable has 137 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function writeShapeTable(XMLWriter $objWriter, ShapeTable $shape, int $shapeId): void
            {
                // p:graphicFrame
                $objWriter->startElement('p:graphicFrame');
                // p:graphicFrame/p:nvGraphicFramePr
        Severity: Major
        Found in src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php - About 5 hrs to fix

          Function writeShapeTable has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function writeShapeTable(XMLWriter $objWriter, ShapeTable $shape, int $shapeId): void
              {
                  // p:graphicFrame
                  $objWriter->startElement('p:graphicFrame');
                  // p:graphicFrame/p:nvGraphicFramePr
          Severity: Minor
          Found in src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php - About 5 hrs 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 writeSeriesStyle has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function writeSeriesStyle(Chart $chart, Chart\Series $series): void
              {
                  $chartType = $chart->getPlotArea()->getType();
          
                  // style:style
          Severity: Minor
          Found in src/PhpPresentation/Writer/ODPresentation/ObjectsChart.php - About 5 hrs 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

          Axis has 40 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Axis implements ComparableInterface
          {
              public const AXIS_X = 'x';
              public const AXIS_Y = 'y';
          
          
          Severity: Minor
          Found in src/PhpPresentation/Shape/Chart/Axis.php - About 5 hrs to fix

            Series has 40 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Series implements ComparableInterface
            {
                // Label positions
                public const LABEL_BESTFIT = 'bestFit';
                public const LABEL_BOTTOM = 'b';
            Severity: Minor
            Found in src/PhpPresentation/Shape/Chart/Series.php - About 5 hrs to fix

              Method writeNote has 131 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function writeNote(Note $pNote): string
                  {
                      // Create XML writer
                      $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
              
              
              Severity: Major
              Found in src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php - About 5 hrs to fix

                Method readStructureTextPFRun has 130 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function readStructureTextPFRun(string $stream, int $pos, int $strLenRT): array
                    {
                        $arrayReturn = [
                            'length' => 0,
                            'strLenRT' => $strLenRT,
                Severity: Major
                Found in src/PhpPresentation/Reader/PowerPoint97.php - About 5 hrs to fix

                  Function loadShapeRichText has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function loadShapeRichText(XMLReader $document, DOMElement $node, $oSlide): void
                      {
                          // Core
                          $oShape = $oSlide->createRichTextShape();
                          $oShape->setParagraphs([]);
                  Severity: Minor
                  Found in src/PhpPresentation/Reader/PowerPoint2007.php - About 5 hrs 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 writeShapeText has 126 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function writeShapeText(XMLWriter $objWriter, RichText $shape, int $shapeId): void
                      {
                          // p:sp
                          $objWriter->startElement('p:sp');
                          // p:sp\p:nvSpPr
                  Severity: Major
                  Found in src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php - About 5 hrs to fix

                    Method loadShapeTable has 124 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function loadShapeTable(XMLReader $document, DOMElement $node, AbstractSlide $oSlide): void
                        {
                            $this->fileRels = $oSlide->getRelsIndex();
                    
                            $oShape = $oSlide->createTableShape();
                    Severity: Major
                    Found in src/PhpPresentation/Reader/PowerPoint2007.php - About 4 hrs to fix

                      Function loadShadow has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function loadShadow(XMLReader $document, DOMElement $node): ?Shadow
                          {
                              if ($node instanceof DOMElement) {
                                  $aNodes = $document->getElements('*', $node);
                                  foreach ($aNodes as $nodeShadow) {
                      Severity: Minor
                      Found in src/PhpPresentation/Reader/PowerPoint2007.php - About 4 hrs 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

                      Font has 37 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      class Font implements ComparableInterface
                      {
                          // Capitalization type
                          public const CAPITALIZATION_NONE = 'none';
                          public const CAPITALIZATION_SMALL = 'small';
                      Severity: Minor
                      Found in src/PhpPresentation/Style/Font.php - About 4 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language