CaffGeek/MBACNationals

View on GitHub
Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php

Summary

Maintainability
F
3 wks
Test Coverage

Function Analyze has a Cognitive Complexity of 341 (exceeds 5 allowed). Consider refactoring.
Open

    public function Analyze() {
        $info = &$this->getid3->info;

        // initialize these values to an empty array, otherwise they default to NULL
        // and you can't append array values to a NULL value

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

    public function Analyze() {
        $info = &$this->getid3->info;

        // initialize these values to an empty array, otherwise they default to NULL
        // and you can't append array values to a NULL value
Severity: Major
Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php - About 4 days to fix

    File module.audio-video.riff.php has 1460 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /////////////////////////////////////////////////////////////////
    /// getID3() by James Heinrich <info@getid3.org>               //
    //  available at http://getid3.sourceforge.net                 //
    //            or http://www.getid3.org                         //
    Severity: Major
    Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php - About 3 days to fix

      Function ParseRIFF has a Cognitive Complexity of 160 (exceeds 5 allowed). Consider refactoring.
      Open

          public function ParseRIFF($startoffset, $maxoffset) {
              $info = &$this->getid3->info;
      
              $RIFFchunk = false;
              $FoundAllChunksWeNeed = false;
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php - About 3 days 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 ParseRIFF has 231 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function ParseRIFF($startoffset, $maxoffset) {
              $info = &$this->getid3->info;
      
              $RIFFchunk = false;
              $FoundAllChunksWeNeed = false;
      Severity: Major
      Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php - About 1 day to fix

        Method parseComments has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function parseComments(&$RIFFinfoArray, &$CommentsTargetArray) {
                $RIFFinfoKeyLookup = array(
                    'IARL'=>'archivallocation',
                    'IART'=>'artist',
                    'ICDS'=>'costumedesigner',
        Severity: Major
        Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php - About 2 hrs to fix

          Function parseComments has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function parseComments(&$RIFFinfoArray, &$CommentsTargetArray) {
                  $RIFFinfoKeyLookup = array(
                      'IARL'=>'archivallocation',
                      'IART'=>'artist',
                      'ICDS'=>'costumedesigner',
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php - About 2 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 ParseDIVXTAG has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function ParseDIVXTAG($DIVXTAG, $raw=false) {
                  // structure from "IDivX" source, Form1.frm, by "Greg Frazier of Daemonic Software Group", email: gfrazier@icestorm.net, web: http://dsg.cjb.net/
                  // source available at http://files.divx-digest.com/download/c663efe7ef8ad2e90bf4af4d3ea6188a/on0SWN2r/edit/IDivX.zip
                  // 'Byte Layout:                   '1111111111111111
                  // '32 for Movie - 1               '1111111111111111
          Severity: Major
          Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php - About 2 hrs to fix

            Method parseWavPackHeader has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function parseWavPackHeader($WavPackChunkData) {
                    // typedef struct {
                    //     char ckID [4];
                    //     long ckSize;
                    //     short version;

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

                  public function ParseRIFFdata(&$RIFFdata) {
                      $info = &$this->getid3->info;
                      if ($RIFFdata) {
                          $tempfile = tempnam(GETID3_TEMP_DIR, 'getID3');
                          $fp_temp  = fopen($tempfile, 'wb');

                Avoid deeply nested control flow statements.
                Open

                                                        if ($chunkname == 'JUNK') {
                                                            if (preg_match('#^([\\x20-\\x7F]+)#', $RIFFchunk[$chunkname][$thisindex]['data'], $matches)) {
                                                                // only keep text characters [chr(32)-chr(127)]
                                                                $info['riff']['comments']['junk'][] = trim($matches[1]);
                                                            }
                Severity: Major
                Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                                          if (!empty($getid3_temp->info['warning'])) {
                                                              foreach ($getid3_temp->info['warning'] as $newerror) {
                                                                  $this->warning('getid3_ac3() says: ['.$newerror.']');
                                                              }
                                                          }
                  Severity: Major
                  Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                    switch ($thisfile_riff_audio['codec_fourcc']) {
                                                        // http://developer.apple.com/qa/snd/snd07.html
                                                        case 'sowt':
                                                            $thisfile_riff_audio['codec_name'] = 'Two\'s Compliment Little-Endian PCM';
                                                            $thisfile_audio['lossless'] = true;
                    Severity: Major
                    Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                  if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strh'][$i]['data'])) {
                                                      $strhData = $thisfile_riff['AVI ']['hdrl']['strl']['strh'][$i]['data'];
                                                      $strhfccType = substr($strhData,  0, 4);
                      
                                                      if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strf'][$i]['data'])) {
                      Severity: Major
                      Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                            if (preg_match('/^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]/s', $FirstFourBytes)) {
                                                                // MP3
                                                                if (getid3_mp3::MPEGaudioHeaderBytesValid($FirstFourBytes)) {
                                                                    $getid3_temp = new getID3();
                                                                    $getid3_temp->openfile($this->getid3->filename);
                        Severity: Major
                        Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                      if (isset($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'])) {
                          
                                                          $thisfile_video['fourcc'] = $thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'];
                                                          if (self::fourccLookup($thisfile_video['fourcc'])) {
                                                              $thisfile_riff_video_current['codec'] = self::fourccLookup($thisfile_video['fourcc']);
                          Severity: Major
                          Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                                    if (empty($getid3_temp->info['error'])) {
                                                                        $info['audio'] = $getid3_temp->info['audio'];
                                                                        $info['mpeg']  = $getid3_temp->info['mpeg'];
                                                                    }
                            Severity: Major
                            Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                                      if (!empty($getid3_temp->info['warning'])) {
                                                                          foreach ($getid3_temp->info['warning'] as $newerror) {
                                                                              $this->warning('getid3_dts() says: ['.$newerror.']');
                                                                          }
                                                                      }
                              Severity: Major
                              Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                                if (substr($DIVXTAG, -7) == 'DIVXTAG') {
                                                                    // DIVXTAG is supposed to be inside an IDVX chunk in a LIST chunk, but some bad encoders just slap it on the end of a file
                                                                    $this->warning('Found wrongly-structured DIVXTAG at offset '.($this->ftell() - 128).', parsing anyway');
                                                                    $info['divxtag']['comments'] = self::ParseDIVXTAG($DIVXTAG);
                                                                    break 2;
                                Severity: Major
                                Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php - About 45 mins to fix

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

                                      public static function ParseDIVXTAG($DIVXTAG, $raw=false) {
                                          // structure from "IDivX" source, Form1.frm, by "Greg Frazier of Daemonic Software Group", email: gfrazier@icestorm.net, web: http://dsg.cjb.net/
                                          // source available at http://files.divx-digest.com/download/c663efe7ef8ad2e90bf4af4d3ea6188a/on0SWN2r/edit/IDivX.zip
                                          // 'Byte Layout:                   '1111111111111111
                                          // '32 for Movie - 1               '1111111111111111
                                  Severity: Minor
                                  Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.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

                                  Avoid too many return statements within this method.
                                  Open

                                          return true;
                                  Severity: Major
                                  Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php - About 30 mins to fix

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

                                                        if (($thisfile_riff_raw_rgad_album['name'] != 0) && ($thisfile_riff_raw_rgad_album['originator'] != 0)) {
                                                            $thisfile_riff['rgad']['album']['name']       = getid3_lib::RGADnameLookup($thisfile_riff_raw_rgad_album['name']);
                                                            $thisfile_riff['rgad']['album']['originator'] = getid3_lib::RGADoriginatorLookup($thisfile_riff_raw_rgad_album['originator']);
                                                            $thisfile_riff['rgad']['album']['adjustment'] = getid3_lib::RGADadjustmentLookup($thisfile_riff_raw_rgad_album['adjustment'], $thisfile_riff_raw_rgad_album['signbit']);
                                                        }
                                    Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php on lines 244..248

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

                                    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 (($thisfile_riff_raw_rgad_track['name'] != 0) && ($thisfile_riff_raw_rgad_track['originator'] != 0)) {
                                                            $thisfile_riff['rgad']['track']['name']            = getid3_lib::RGADnameLookup($thisfile_riff_raw_rgad_track['name']);
                                                            $thisfile_riff['rgad']['track']['originator']      = getid3_lib::RGADoriginatorLookup($thisfile_riff_raw_rgad_track['originator']);
                                                            $thisfile_riff['rgad']['track']['adjustment']      = getid3_lib::RGADadjustmentLookup($thisfile_riff_raw_rgad_track['adjustment'], $thisfile_riff_raw_rgad_track['signbit']);
                                                        }
                                    Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php on lines 249..253

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

                                    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

                                                                if (($info['avdataend'] - $info['filesize']) == 1) {
                                                                    // LiteWave appears to incorrectly *not* pad actual output file
                                                                    // to nearest WORD boundary so may appear to be short by one
                                                                    // byte, in which case - skip warning
                                                                } else {
                                    Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php on lines 564..573

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

                                    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

                                                                if ((($info['avdataend'] - $info['filesize']) == 1) && (($thisfile_riff[$RIFFsubtype]['data'][0]['size'] % 2) == 0) && ((($info['filesize'] - $info['avdataoffset']) % 2) == 1)) {
                                                                    // output file appears to be incorrectly *not* padded to nearest WORD boundary
                                                                    // Output less severe warning
                                                                    $info['warning'][] = 'File should probably be padded to nearest WORD boundary, but it is not (expecting '.$thisfile_riff[$RIFFsubtype]['data'][0]['size'].' bytes of data, only found '.($info['filesize'] - $info['avdataoffset']).' therefore short by '.($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($info['filesize'] - $info['avdataoffset'])).' bytes)';
                                                                    $info['avdataend'] = $info['filesize'];
                                    Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php on lines 552..560

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

                                    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 (!empty($info['dts'])) {
                                                                    // Dolby DTS files masquerade as PCM-WAV, but they're not
                                                                    $thisfile_audio['wformattag']  = 0x2001;
                                                                    $thisfile_audio['codec']       = self::wFormatTagLookup($thisfile_audio['wformattag']);
                                                                    $thisfile_audio['lossless']    = false;
                                    Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php on lines 467..474

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

                                    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 (!empty($info['ac3'])) {
                                                                    // Dolby Digital WAV files masquerade as PCM-WAV, but they're not
                                                                    $thisfile_audio['wformattag']  = 0x2000;
                                                                    $thisfile_audio['codec']       = self::wFormatTagLookup($thisfile_audio['wformattag']);
                                                                    $thisfile_audio['lossless']    = false;
                                    Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.riff.php on lines 475..482

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

                                    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

                                    There are no issues that match your filters.

                                    Category
                                    Status