PHPOffice/PHPPresentation

View on GitHub

Showing 325 of 325 total issues

Function readRecordOfficeArtClientTextbox has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    private function readRecordOfficeArtClientTextbox(string $stream, int $pos)
    {
        $arrayReturn = [
            'length' => 0,
            'text' => '',
Severity: Minor
Found in src/PhpPresentation/Reader/PowerPoint97.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

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

                        if (0x0 == $targetAtom['recVer'] && 0x001 == $targetAtom['recInstance'] && self::RT_CSTRING == $targetAtom['recType'] && $targetAtom['recLen'] % 2 == 0) {
                            $pos += 8;
                            $exObjList['recLen'] -= 8;
                            $this->arrayHyperlinks[$exHyperlinkId]['url'] = '';
                            for ($inc = 0; $inc < ($targetAtom['recLen'] / 2); ++$inc) {
Severity: Major
Found in src/PhpPresentation/Reader/PowerPoint97.php and 1 other location - About 4 hrs to fix
src/PhpPresentation/Reader/PowerPoint97.php on lines 778..788

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

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 (0x0 == $friendlyNameAtom['recVer'] && 0x000 == $friendlyNameAtom['recInstance'] && self::RT_CSTRING == $friendlyNameAtom['recType'] && $friendlyNameAtom['recLen'] % 2 == 0) {
                            $pos += 8;
                            $exObjList['recLen'] -= 8;
                            $this->arrayHyperlinks[$exHyperlinkId]['text'] = '';
                            for ($inc = 0; $inc < ($friendlyNameAtom['recLen'] / 2); ++$inc) {
Severity: Major
Found in src/PhpPresentation/Reader/PowerPoint97.php and 1 other location - About 4 hrs to fix
src/PhpPresentation/Reader/PowerPoint97.php on lines 791..801

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

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

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

    Method loadMasterSlide has 112 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function loadMasterSlide(string $sPart, string $baseFile): void
        {
            $xmlReader = new XMLReader();
            // @phpstan-ignore-next-line
            if ($xmlReader->getDomFromString($sPart)) {
    Severity: Major
    Found in src/PhpPresentation/Reader/PowerPoint2007.php - About 4 hrs to fix

      Method displayShapeInfo has 108 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function displayShapeInfo(AbstractShape $oShape): void
          {
              $this->append('<div class="infoBlk" id="div' . $oShape->getHashCode() . 'Info">');
              $this->append('<dl>');
              $this->append('<dt>HashCode</dt><dd>' . $oShape->getHashCode() . '</dd>');
      Severity: Major
      Found in samples/Sample_Header.php - About 4 hrs to fix

        Method writeShapeTxt has 108 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function writeShapeTxt(XMLWriter $objWriter, RichText $shape): void
            {
                // draw:frame
                $objWriter->startElement('draw:frame');
                $objWriter->writeAttribute('draw:style-name', 'gr' . $this->shapeId);
        Severity: Major
        Found in src/PhpPresentation/Writer/ODPresentation/Content.php - About 4 hrs to fix

          Method writeTypeBar has 107 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function writeTypeBar(XMLWriter $objWriter, Bar $subject, bool $includeSheet = false): void
              {
                  // c:barChart
                  $objWriter->startElement('c:barChart');
          
          
          Severity: Major
          Found in src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php - About 4 hrs to fix

            Method writeSeriesStyle has 103 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function writeSeriesStyle(Chart $chart, Chart\Series $series): void
                {
                    $chartType = $chart->getPlotArea()->getType();
            
                    // style:style
            Severity: Major
            Found in src/PhpPresentation/Writer/ODPresentation/ObjectsChart.php - About 4 hrs to fix

              Method writeSlideMaster has 103 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function writeSlideMaster(SlideMaster $pSlide): string
                  {
                      // Create XML writer
                      $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
                      // XML header
              Severity: Major
              Found in src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php - About 4 hrs to fix

                Function writeTxtStyle has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function writeTxtStyle(XMLWriter $objWriter, RichText $shape): void
                    {
                        // style:style
                        $objWriter->startElement('style:style');
                        $objWriter->writeAttribute('style:name', 'gr' . $this->shapeId);
                Severity: Minor
                Found in src/PhpPresentation/Writer/ODPresentation/Content.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

                Function displayPhpPresentationInfo has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function displayPhpPresentationInfo(PhpPresentation $oPHPPpt): void
                    {
                        $this->append('<div class="infoBlk" id="divPhpPresentationInfo">');
                        $this->append('<dl>');
                        $this->append('<dt>Number of slides</dt><dd>' . $oPHPPpt->getSlideCount() . '</dd>');
                Severity: Minor
                Found in samples/Sample_Header.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

                Function readStructureTextPFRun has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                Open

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

                Method writeContentPart has 99 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function writeContentPart(Chart $chart): string
                    {
                        $this->xmlContent = new XMLWriter(XMLWriter::STORAGE_MEMORY);
                
                        $chartType = $chart->getPlotArea()->getType();
                Severity: Major
                Found in src/PhpPresentation/Writer/ODPresentation/ObjectsChart.php - About 3 hrs to fix

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

                                      case 0x0183:
                                          // Fill : fillBackColor
                                          //@link : http://msdn.microsoft.com/en-us/library/dd950634(v=office.12).aspx
                                          $strColor = str_pad(dechex(($opt['op'] >> 0) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
                                          $strColor .= str_pad(dechex(($opt['op'] >> 8) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
                  Severity: Major
                  Found in src/PhpPresentation/Reader/PowerPoint97.php and 1 other location - About 3 hrs to fix
                  src/PhpPresentation/Reader/PowerPoint97.php on lines 2136..2144

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

                  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

                                      case 0x0181:
                                          // Fill : fillColor
                                          //@link : http://msdn.microsoft.com/en-us/library/dd921332(v=office.12).aspx
                                          $strColor = str_pad(dechex(($opt['op'] >> 0) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
                                          $strColor .= str_pad(dechex(($opt['op'] >> 8) & bindec('11111111')), 2, '0', STR_PAD_LEFT);
                  Severity: Major
                  Found in src/PhpPresentation/Reader/PowerPoint97.php and 1 other location - About 3 hrs to fix
                  src/PhpPresentation/Reader/PowerPoint97.php on lines 2145..2153

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

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

                      private function readRecordOfficeArtSpgrContainer($stream, $pos, $bInGroup = false)
                      {
                          $arrayReturn = [
                              'length' => 0,
                          ];
                  Severity: Minor
                  Found in src/PhpPresentation/Reader/PowerPoint97.php - About 3 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 writeTypeBar3D has 97 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function writeTypeBar3D(XMLWriter $objWriter, Bar3D $subject, bool $includeSheet = false): void
                      {
                          // c:bar3DChart
                          $objWriter->startElement('c:bar3DChart');
                  
                  
                  Severity: Major
                  Found in src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php - About 3 hrs to fix

                    AbstractShape has 31 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    abstract class AbstractShape implements ComparableInterface
                    {
                        /**
                         * Container.
                         *
                    Severity: Minor
                    Found in src/PhpPresentation/AbstractShape.php - About 3 hrs to fix

                      Method writeShapePic has 95 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function writeShapePic(XMLWriter $objWriter, AbstractGraphic $shape, int $shapeId): void
                          {
                              // p:pic
                              $objWriter->startElement('p:pic');
                      
                      
                      Severity: Major
                      Found in src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php - About 3 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language