CaffGeek/MBACNationals

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

Summary

Maintainability
F
2 wks
Test Coverage

Function parseEBML has a Cognitive Complexity of 275 (exceeds 5 allowed). Consider refactoring.
Open

    private function parseEBML(&$info) {
        // http://www.matroska.org/technical/specs/index.html#EBMLBasics
        $this->current_offset = $info['avdataoffset'];

        while ($this->getEBMLelement($top_element, $info['avdataend'])) {

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

File module.audio-video.matroska.php has 1419 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                         //

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

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

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

        private function parseEBML(&$info) {
            // http://www.matroska.org/technical/specs/index.html#EBMLBasics
            $this->current_offset = $info['avdataoffset'];
    
            while ($this->getEBMLelement($top_element, $info['avdataend'])) {

      Method Analyze has 209 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

        Method EBMLidName has 194 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static function EBMLidName($value) {
                static $EBMLidList = array();
                if (empty($EBMLidList)) {
                    $EBMLidList[EBML_ID_ASPECTRATIOTYPE]            = 'AspectRatioType';
                    $EBMLidList[EBML_ID_ATTACHEDFILE]               = 'AttachedFile';

          Function HandleEMBLClusterBlock has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              private function HandleEMBLClusterBlock($element, $block_type, &$info) {
                  // http://www.matroska.org/technical/specs/index.html#block_structure
                  // http://www.matroska.org/technical/specs/index.html#simpleblock_structure
          
                  $block_data = array();

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

              private function HandleEMBLClusterBlock($element, $block_type, &$info) {
                  // http://www.matroska.org/technical/specs/index.html#block_structure
                  // http://www.matroska.org/technical/specs/index.html#simpleblock_structure
          
                  $block_data = array();

            Method CodecIDtoCommonName has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function CodecIDtoCommonName($codecid) {
                    // http://www.matroska.org/technical/specs/codecid/index.html
                    static $CodecIDlist = array();
                    if (empty($CodecIDlist)) {
                        $CodecIDlist['A_AAC']            = 'aac';

              Function ExtractCommentsSimpleTag has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function ExtractCommentsSimpleTag($SimpleTagArray) {
                      if (!empty($SimpleTagArray['SimpleTag'])) {
                          foreach ($SimpleTagArray['SimpleTag'] as $SimpleTagKey => $SimpleTagData) {
                              if (!empty($SimpleTagData['TagName']) && !empty($SimpleTagData['TagString'])) {
                                  $this->getid3->info['matroska']['comments'][strtolower($SimpleTagData['TagName'])][] = $SimpleTagData['TagString'];

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

                  private function readEBMLint() {
                      $actual_offset = $this->current_offset - $this->EBMLbuffer_offset;
              
                      // get length of integer
                      $first_byte_int = ord($this->EBMLbuffer[$actual_offset]);
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.matroska.php - About 55 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 ($track_info['dataformat'] == 'mp3' && preg_match('/^Probable truncated file: expecting \d+ bytes of audio data, only found \d+ \(short by \d+ bytes\)$/', $newerror)) {
                                                          // LAME/Xing header is probably set, but audio data is chunked into Matroska file and near-impossible to verify if audio stream is complete, so ignore useless warning
                                                          continue;
                                                      }
              Severity: Major
              Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.matroska.php - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                                while ($this->getEBMLelement($seek_entry, $element_data['end'])) {
                                                    switch ($seek_entry['id']) {
                
                                                        case EBML_ID_SEEK: // Contains a single seek entry to an EBML element
                                                            while ($this->getEBMLelement($sub_seek_entry, $seek_entry['end'], true)) {
                Severity: Major
                Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.matroska.php - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                                  if (self::$hide_clusters) { // do not parse cues if hide clusters is "ON" till they point to clusters anyway
                                                      $this->current_offset = $element_data['end'];
                                                      break;
                                                  }
                  Severity: Major
                  Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.matroska.php - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                    while ($this->getEBMLelement($subelement, $element_data['end'], false)) {
                                                        switch ($subelement['id']) {
                    
                                                            case EBML_ID_TAG:
                                                                $tag_entry = array();
                    Severity: Major
                    Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.matroska.php - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                      while ($this->getEBMLelement($subelement, $element_data['end'], array(EBML_ID_CLUSTERSILENTTRACKS, EBML_ID_CLUSTERBLOCKGROUP, EBML_ID_CLUSTERSIMPLEBLOCK))) {
                                                          switch ($subelement['id']) {
                      
                                                              case EBML_ID_CLUSTERTIMECODE:
                                                              case EBML_ID_CLUSTERPOSITION:
                      Severity: Major
                      Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.matroska.php - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                        while ($this->getEBMLelement($subelement, $element_data['end'])) {
                                                            switch ($subelement['id']) {
                        
                                                                case EBML_ID_CUEPOINT:
                                                                    $cuepoint_entry = array();
                        Severity: Major
                        Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.matroska.php - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                          while ($this->getEBMLelement($subelement, $element_data['end'])) {
                                                              switch ($subelement['id']) {
                          
                                                                  case EBML_ID_ATTACHEDFILE:
                                                                      $attachedfile_entry = array();
                          Severity: Major
                          Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.matroska.php - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                            while ($this->getEBMLelement($subelement, $element_data['end'], true)) {
                                                                switch ($subelement['id']) {
                            
                                                                    case EBML_ID_TIMECODESCALE:
                                                                        $info_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']);
                            Severity: Major
                            Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.matroska.php - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                              if (!self::$hide_clusters) {
                                                                  $info['matroska']['cluster'][] = $cluster_entry;
                                                              }
                              Severity: Major
                              Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.matroska.php - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                                if (!self::$parse_whole_file) {
                                                                    if (isset($info['matroska']['info']) && is_array($info['matroska']['info'])) {
                                                                        if (isset($info['matroska']['tracks']['tracks']) && is_array($info['matroska']['tracks']['tracks'])) {
                                                                            if (count($info['matroska']['track_data_offsets']) == count($info['matroska']['tracks']['tracks'])) {
                                                                                return;
                                Severity: Major
                                Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.matroska.php - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                                  while ($this->getEBMLelement($track_entry, $element_data['end'])) {
                                                                      switch ($track_entry['id']) {
                                  
                                                                          case EBML_ID_TRACKENTRY: //subelements: Describes a track with all elements.
                                  
                                  
                                  Severity: Major
                                  Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.matroska.php - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                                    while ($this->getEBMLelement($subelement, $element_data['end'])) {
                                                                        switch ($subelement['id']) {
                                    
                                                                            case EBML_ID_EDITIONENTRY:
                                                                                $editionentry_entry = array();
                                    Severity: Major
                                    Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.matroska.php - About 45 mins to fix

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

                                          private static function EBML2Int($EBMLstring) {
                                              // http://matroska.org/specs/
                                      
                                              // Element ID coded with an UTF-8 like system:
                                              // 1xxx xxxx                                  - Class A IDs (2^7 -2 possible values) (base 0x8X)
                                      Severity: Minor
                                      Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.matroska.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($getid3_temp->info['audio']) && is_array($getid3_temp->info['audio'])) {
                                                                              foreach ($getid3_temp->info['audio'] as $key => $value) {
                                                                                  $track_info[$key] = $value;
                                                                              }
                                                                          }
                                      Severity: Major
                                      Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.matroska.php - About 45 mins to fix

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

                                            private static function getDefaultStreamInfo($streams)
                                            {
                                                foreach (array_reverse($streams) as $stream) {
                                                    if ($stream['default']) {
                                                        break;
                                        Severity: Minor
                                        Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.matroska.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 EnsureBufferHasEnoughData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                            private function EnsureBufferHasEnoughData($min_data=1024) {
                                                if (($this->current_offset - $this->EBMLbuffer_offset) >= ($this->EBMLbuffer_length - $min_data)) {
                                                    $read_bytes = max($min_data, $this->getid3->fread_buffer_size());
                                        
                                                    try {
                                        Severity: Minor
                                        Found in Web.Admin/2014/wordpress/wp-includes/ID3/module.audio-video.matroska.php - About 25 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

                                        There are no issues that match your filters.

                                        Category
                                        Status