CaffGeek/MBACNationals

View on GitHub
Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php

Summary

Maintainability
F
2 wks
Test Coverage

File getid3.php has 1242 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/getid3.php - About 3 days to fix

    Function HandleAllTags has a Cognitive Complexity of 110 (exceeds 5 allowed). Consider refactoring.
    Open

        public function HandleAllTags() {
    
            // key name => array (tag name, character encoding)
            static $tags;
            if (empty($tags)) {
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 2 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 GetFileFormatArray has 379 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function GetFileFormatArray() {
            static $format_info = array();
            if (empty($format_info)) {
                $format_info = array(
    
    
    Severity: Major
    Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 1 day to fix

      Function __construct has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
      Open

          public function __construct() {
      
              // Check for PHP version
              $required_php_version = '5.0.5';
              if (version_compare(PHP_VERSION, $required_php_version, '<')) {
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 1 day 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 analyze has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

          public function analyze($filename) {
              try {
                  if (!$this->openfile($filename)) {
                      return $this->info;
                  }
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.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 getHashdata has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getHashdata($algorithm) {
              switch ($algorithm) {
                  case 'md5':
                  case 'sha1':
                      break;
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.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 analyze has 105 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function analyze($filename) {
              try {
                  if (!$this->openfile($filename)) {
                      return $this->info;
                  }
      Severity: Major
      Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 4 hrs to fix

        Method HandleAllTags has 101 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function HandleAllTags() {
        
                // key name => array (tag name, character encoding)
                static $tags;
                if (empty($tags)) {
        Severity: Major
        Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 4 hrs to fix

          Function ChannelsBitratePlaytimeCalculations has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

              public function ChannelsBitratePlaytimeCalculations() {
          
                  // set channelmode on audio
                  if (!empty($this->info['audio']['channelmode']) || !isset($this->info['audio']['channels'])) {
                      // ignore
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.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 __construct has 72 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function __construct() {
          
                  // Check for PHP version
                  $required_php_version = '5.0.5';
                  if (version_compare(PHP_VERSION, $required_php_version, '<')) {
          Severity: Major
          Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 2 hrs to fix

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

                private function CleanUp() {
            
                    // remove possible empty keys
                    $AVpossibleEmptyKeys = array('dataformat', 'bits_per_sample', 'encoder_options', 'streams', 'bitrate');
                    foreach ($AVpossibleEmptyKeys as $dummy => $key) {
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.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

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

                public function saveAttachment($name, $offset, $length, $image_mime=null) {
                    try {
            
                        // do not extract at all
                        if ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_NONE) {
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.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 getHashdata has 62 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getHashdata($algorithm) {
                    switch ($algorithm) {
                        case 'md5':
                        case 'sha1':
                            break;
            Severity: Major
            Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 2 hrs to fix

              Method openfile has 58 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function openfile($filename) {
                      try {
                          if (!empty($this->startup_error)) {
                              throw new getid3_exception($this->startup_error);
                          }
              Severity: Major
              Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 2 hrs to fix

                Function openfile has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function openfile($filename) {
                        try {
                            if (!empty($this->startup_error)) {
                                throw new getid3_exception($this->startup_error);
                            }
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.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

                getID3 has 21 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class getID3
                {
                    // public: Settings
                    public $encoding        = 'UTF-8';        // CASE SENSITIVE! - i.e. (must be supported by iconv()). Examples:  ISO-8859-1  UTF-8  UTF-16  UTF-16BE
                    public $encoding_id3v1  = 'ISO-8859-1';   // Should always be 'ISO-8859-1', but some tags may be written in other encodings such as 'EUC-CN' or 'CP1252'
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 2 hrs to fix

                  Method CalculateCompressionRatioVideo has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function CalculateCompressionRatioVideo() {
                          if (empty($this->info['video'])) {
                              return false;
                          }
                          if (empty($this->info['video']['resolution_x']) || empty($this->info['video']['resolution_y'])) {
                  Severity: Minor
                  Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 1 hr to fix

                    Method saveAttachment has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function saveAttachment($name, $offset, $length, $image_mime=null) {
                            try {
                    
                                // do not extract at all
                                if ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_NONE) {
                    Severity: Minor
                    Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 1 hr to fix

                      Function CalculateCompressionRatioVideo has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function CalculateCompressionRatioVideo() {
                              if (empty($this->info['video'])) {
                                  return false;
                              }
                              if (empty($this->info['video']['resolution_x']) || empty($this->info['video']['resolution_y'])) {
                      Severity: Minor
                      Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 1 hr 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 ChannelsBitratePlaytimeCalculations has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function ChannelsBitratePlaytimeCalculations() {
                      
                              // set channelmode on audio
                              if (!empty($this->info['audio']['channelmode']) || !isset($this->info['audio']['channels'])) {
                                  // ignore
                      Severity: Minor
                      Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 1 hr to fix

                        Function fseek has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected function fseek($bytes, $whence=SEEK_SET) {
                                if ($this->data_string_flag) {
                                    switch ($whence) {
                                        case SEEK_SET:
                                            $this->data_string_position = $bytes;
                        Severity: Minor
                        Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 1 hr 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 CleanUp has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function CleanUp() {
                        
                                // remove possible empty keys
                                $AVpossibleEmptyKeys = array('dataformat', 'bits_per_sample', 'encoder_options', 'streams', 'bitrate');
                                foreach ($AVpossibleEmptyKeys as $dummy => $key) {
                        Severity: Minor
                        Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 1 hr to fix

                          Function ProcessAudioStreams has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function ProcessAudioStreams() {
                                  if (!empty($this->info['audio']['bitrate']) || !empty($this->info['audio']['channels']) || !empty($this->info['audio']['sample_rate'])) {
                                      if (!isset($this->info['audio']['streams'])) {
                                          foreach ($this->info['audio'] as $key => $value) {
                                              if ($key != 'streams') {
                          Severity: Minor
                          Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 1 hr 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 CalculateReplayGain has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function CalculateReplayGain() {
                                  if (isset($this->info['replay_gain'])) {
                                      if (!isset($this->info['replay_gain']['reference_volume'])) {
                                          $this->info['replay_gain']['reference_volume'] = (double) 89.0;
                                      }
                          Severity: Minor
                          Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 1 hr 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 CalculateCompressionRatioAudio has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function CalculateCompressionRatioAudio() {
                                  if (empty($this->info['audio']['bitrate']) || empty($this->info['audio']['channels']) || empty($this->info['audio']['sample_rate']) || !is_numeric($this->info['audio']['sample_rate'])) {
                                      return false;
                                  }
                                  $this->info['audio']['compression_ratio'] = $this->info['audio']['bitrate'] / ($this->info['audio']['channels'] * $this->info['audio']['sample_rate'] * (!empty($this->info['audio']['bits_per_sample']) ? $this->info['audio']['bits_per_sample'] : 16));
                          Severity: Minor
                          Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.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 ((strtoupper($filesize) == '<DIR>') && (strtolower($filename) == strtolower($value))) {
                                                                  $value = $shortname;
                                                              }
                          Severity: Major
                          Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 45 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return $this->error('Format not supported, module "'.$determined_format['include'].'" was removed.');
                            Severity: Major
                            Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return $this->error($errormessage);
                              Severity: Major
                              Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                    return false;
                                Severity: Major
                                Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                  return $this->error('Format not supported, module "'.$determined_format['include'].'" is corrupt.');
                                  Severity: Major
                                  Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

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

                                      Avoid too many return statements within this method.
                                      Open

                                              return $this->info;
                                      Severity: Major
                                      Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                            return false;
                                        Severity: Major
                                        Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.php - About 30 mins to fix

                                          Function setOption has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              public function setOption($optArray) {
                                                  if (!is_array($optArray) || empty($optArray)) {
                                                      return false;
                                                  }
                                                  foreach ($optArray as $opt => $val) {
                                          Severity: Minor
                                          Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.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

                                          Function GetFileFormat has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              public function GetFileFormat(&$filedata, $filename='') {
                                                  // this function will determine the format of a file based on usually
                                                  // the first 2-4 bytes of the file (8 bytes for PNG, 16 bytes for JPG,
                                                  // and in the case of ISO CD image, 6 bytes offset 32kb from the start
                                                  // of the file).
                                          Severity: Minor
                                          Found in Web.Admin/2014/wordpress/wp-includes/ID3/getid3.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