wikimedia/mediawiki-core

View on GitHub
includes/upload/UploadBase.php

Summary

Maintainability
F
2 wks
Test Coverage

File UploadBase.php has 1378 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Base class for the backend of file upload.
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Major
Found in includes/upload/UploadBase.php - About 3 days to fix

    UploadBase has 73 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class UploadBase {
        use ProtectedHookAccessorTrait;
    
        /** @var string|null Local file system path to the file to upload (or a local copy) */
        protected $mTempPath;
    Severity: Major
    Found in includes/upload/UploadBase.php - About 1 day to fix

      Method checkSvgScriptCallback has 162 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function checkSvgScriptCallback( $element, $attribs, $data = null ) {
              [ $namespace, $strippedElement ] = self::splitXmlNamespace( $element );
      
              // We specifically don't include:
              // http://www.w3.org/1999/xhtml (T62771)
      Severity: Major
      Found in includes/upload/UploadBase.php - About 6 hrs to fix

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

            public function checkSvgScriptCallback( $element, $attribs, $data = null ) {
                [ $namespace, $strippedElement ] = self::splitXmlNamespace( $element );
        
                // We specifically don't include:
                // http://www.w3.org/1999/xhtml (T62771)
        Severity: Minor
        Found in includes/upload/UploadBase.php - About 5 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

            public function getTitle() {
                if ( $this->mTitle !== false ) {
                    return $this->mTitle;
                }
                if ( !is_string( $this->mDesiredDestName ) ) {
        Severity: Minor
        Found in includes/upload/UploadBase.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 getTitle has 94 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getTitle() {
                if ( $this->mTitle !== false ) {
                    return $this->mTitle;
                }
                if ( !is_string( $this->mDesiredDestName ) ) {
        Severity: Major
        Found in includes/upload/UploadBase.php - About 3 hrs to fix

          Method detectVirus has 71 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function detectVirus( $file ) {
                  global $wgOut;
                  $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
                  $antivirus = $mainConfig->get( MainConfigNames::Antivirus );
                  $antivirusSetup = $mainConfig->get( MainConfigNames::AntivirusSetup );
          Severity: Major
          Found in includes/upload/UploadBase.php - About 2 hrs to fix

            Function detectScript has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function detectScript( $file, $mime, $extension ) {
                    # ugly hack: for text files, always look at the entire file.
                    # For binary field, just check the first K.
            
                    if ( str_starts_with( $mime ?? '', 'text/' ) ) {
            Severity: Minor
            Found in includes/upload/UploadBase.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 detectScript has 66 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function detectScript( $file, $mime, $extension ) {
                    # ugly hack: for text files, always look at the entire file.
                    # For binary field, just check the first K.
            
                    if ( str_starts_with( $mime ?? '', 'text/' ) ) {
            Severity: Major
            Found in includes/upload/UploadBase.php - About 2 hrs to fix

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

                  public static function detectVirus( $file ) {
                      global $wgOut;
                      $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
                      $antivirus = $mainConfig->get( MainConfigNames::Antivirus );
                      $antivirusSetup = $mainConfig->get( MainConfigNames::AntivirusSetup );
              Severity: Minor
              Found in includes/upload/UploadBase.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 verifyFile has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function verifyFile() {
                      $config = MediaWikiServices::getInstance()->getMainConfig();
                      $verifyMimeType = $config->get( MainConfigNames::VerifyMimeType );
                      $disableUploadScriptChecks = $config->get( MainConfigNames::DisableUploadScriptChecks );
                      $status = $this->verifyPartialFile();
              Severity: Minor
              Found in includes/upload/UploadBase.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 getExistsWarning has 64 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function getExistsWarning( $file ) {
                      if ( $file->exists() ) {
                          return [ 'warning' => 'exists', 'file' => $file ];
                      }
              
              
              Severity: Major
              Found in includes/upload/UploadBase.php - About 2 hrs to fix

                Method verifyFile has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function verifyFile() {
                        $config = MediaWikiServices::getInstance()->getMainConfig();
                        $verifyMimeType = $config->get( MainConfigNames::VerifyMimeType );
                        $disableUploadScriptChecks = $config->get( MainConfigNames::DisableUploadScriptChecks );
                        $status = $this->verifyPartialFile();
                Severity: Minor
                Found in includes/upload/UploadBase.php - About 1 hr to fix

                  Function getExistsWarning has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function getExistsWarning( $file ) {
                          if ( $file->exists() ) {
                              return [ 'warning' => 'exists', 'file' => $file ];
                          }
                  
                  
                  Severity: Minor
                  Found in includes/upload/UploadBase.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 checkXMLEncodingMissmatch has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function checkXMLEncodingMissmatch( $file ) {
                          // https://mimesniff.spec.whatwg.org/#resource-header says browsers
                          // should read the first 1445 bytes. Do 4096 bytes for good measure.
                          // XML Spec says XML declaration if present must be first thing in file
                          // other than BOM
                  Severity: Minor
                  Found in includes/upload/UploadBase.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 setSessionStatus has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function setSessionStatus( UserIdentity $user, $statusKey, $value ) {
                          $store = self::getUploadSessionStore();
                          $key = self::getUploadSessionKey( $store, $user, $statusKey );
                          $logger = LoggerFactory::getInstance( 'upload' );
                  
                  
                  Severity: Minor
                  Found in includes/upload/UploadBase.php - About 1 hr to fix

                    Method checkWarnings has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function checkWarnings( $user = null ) {
                            if ( $user === null ) {
                                // TODO check uses and hard deprecate
                                $user = RequestContext::getMain()->getUser();
                            }
                    Severity: Minor
                    Found in includes/upload/UploadBase.php - About 1 hr to fix

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

                          protected function verifyPartialFile() {
                              $config = MediaWikiServices::getInstance()->getMainConfig();
                              $disableUploadScriptChecks = $config->get( MainConfigNames::DisableUploadScriptChecks );
                              # getTitle() sets some internal parameters like $this->mFinalExtension
                              $this->getTitle();
                      Severity: Minor
                      Found in includes/upload/UploadBase.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 checkCssFragment has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private static function checkCssFragment( $value ) {
                              # Forbid external stylesheets, for both reliability and to protect viewer's privacy
                              if ( stripos( $value, '@import' ) !== false ) {
                                  return true;
                              }
                      Severity: Minor
                      Found in includes/upload/UploadBase.php - About 1 hr to fix

                        Method checkXMLEncodingMissmatch has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public static function checkXMLEncodingMissmatch( $file ) {
                                // https://mimesniff.spec.whatwg.org/#resource-header says browsers
                                // should read the first 1445 bytes. Do 4096 bytes for good measure.
                                // XML Spec says XML declaration if present must be first thing in file
                                // other than BOM
                        Severity: Minor
                        Found in includes/upload/UploadBase.php - About 1 hr to fix

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

                              protected function verifyPartialFile() {
                                  $config = MediaWikiServices::getInstance()->getMainConfig();
                                  $disableUploadScriptChecks = $config->get( MainConfigNames::DisableUploadScriptChecks );
                                  # getTitle() sets some internal parameters like $this->mFinalExtension
                                  $this->getTitle();
                          Severity: Minor
                          Found in includes/upload/UploadBase.php - About 1 hr to fix

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

                                public function performUpload(
                                    $comment, $pageText, $watch, $user, $tags = [], ?string $watchlistExpiry = null
                                ) {
                                    $this->getLocalFile()->load( IDBAccessObject::READ_LATEST );
                                    $props = $this->mFileProps;
                            Severity: Minor
                            Found in includes/upload/UploadBase.php - About 1 hr to fix

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

                                  public static function getFilenamePrefixBlacklist() {
                                      $list = [];
                                      $message = wfMessage( 'filename-prefix-blacklist' )->inContentLanguage();
                                      if ( !$message->isDisabled() ) {
                                          $lines = explode( "\n", $message->plain() );
                              Severity: Minor
                              Found in includes/upload/UploadBase.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 verifyExtension has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public static function verifyExtension( $mime, $extension ) {
                                      $magic = MediaWikiServices::getInstance()->getMimeAnalyzer();
                              
                                      if ( !$mime || $mime === 'unknown' || $mime === 'unknown/unknown' ) {
                                          if ( !$magic->isRecognizableExtension( $extension ) ) {
                              Severity: Minor
                              Found in includes/upload/UploadBase.php - About 1 hr to fix

                                Function checkLocalFileExists has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    private function checkLocalFileExists( LocalFile $localFile, $hash ) {
                                        $warnings = [];
                                
                                        $exists = self::getExistsWarning( $localFile );
                                        if ( $exists !== false ) {
                                Severity: Minor
                                Found in includes/upload/UploadBase.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

                                Function checkCssFragment has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    private static function checkCssFragment( $value ) {
                                        # Forbid external stylesheets, for both reliability and to protect viewer's privacy
                                        if ( stripos( $value, '@import' ) !== false ) {
                                            return true;
                                        }
                                Severity: Minor
                                Found in includes/upload/UploadBase.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

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

                                    public static function unserializeWarnings( $warnings ) {
                                        foreach ( $warnings as $key => $value ) {
                                            if ( is_array( $value ) ) {
                                                if ( isset( $value['fileName'] ) && isset( $value['timestamp'] ) ) {
                                                    $warnings[$key] = MediaWikiServices::getInstance()->getRepoGroup()->findFile(
                                Severity: Minor
                                Found in includes/upload/UploadBase.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

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

                                    public static function verifyExtension( $mime, $extension ) {
                                        $magic = MediaWikiServices::getInstance()->getMimeAnalyzer();
                                
                                        if ( !$mime || $mime === 'unknown' || $mime === 'unknown/unknown' ) {
                                            if ( !$magic->isRecognizableExtension( $extension ) ) {
                                Severity: Minor
                                Found in includes/upload/UploadBase.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

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

                                    public function validateName() {
                                        $nt = $this->getTitle();
                                        if ( $nt === null ) {
                                            $result = [ 'status' => $this->mTitleError ];
                                            if ( $this->mTitleError === self::ILLEGAL_FILENAME ) {
                                Severity: Minor
                                Found in includes/upload/UploadBase.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

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

                                    public function checkWarnings( $user = null ) {
                                        if ( $user === null ) {
                                            // TODO check uses and hard deprecate
                                            $user = RequestContext::getMain()->getUser();
                                        }
                                Severity: Minor
                                Found in includes/upload/UploadBase.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

                                Method performUpload has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                        $comment, $pageText, $watch, $user, $tags = [], ?string $watchlistExpiry = null
                                Severity: Minor
                                Found in includes/upload/UploadBase.php - About 45 mins to fix

                                  Consider simplifying this complex logical expression.
                                  Open

                                              if (
                                                  $stripped === 'href'
                                                  && $value !== ''
                                                  && !str_starts_with( $value, 'data:' )
                                                  && !str_starts_with( $value, '#' )
                                  Severity: Major
                                  Found in includes/upload/UploadBase.php - About 40 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                return [ 'uploaded-hostile-svg' ];
                                    Severity: Major
                                    Found in includes/upload/UploadBase.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                      return [ 'uploaded-event-handler-on-svg', $attrib, $value ];
                                      Severity: Major
                                      Found in includes/upload/UploadBase.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                        return [ 'uploaded-image-filter-svg', $strippedElement, $stripped, $value ];
                                        Severity: Major
                                        Found in includes/upload/UploadBase.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                      return [
                                                          'warning' => 'thumb-name',
                                                          'file' => $file,
                                                          'thumbFile' => $file_thb
                                                      ];
                                          Severity: Major
                                          Found in includes/upload/UploadBase.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                        return $this->mTitle;
                                            Severity: Major
                                            Found in includes/upload/UploadBase.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                      return true;
                                              Severity: Major
                                              Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                                return [ 'uploaded-remote-url-svg', $attrib, $value ];
                                                Severity: Major
                                                Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                          return $this->mTitle;
                                                  Severity: Major
                                                  Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                            return false;
                                                    Severity: Major
                                                    Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                                      return [ 'uploaded-setting-event-handler-svg', $strippedElement, $stripped, $value ];
                                                      Severity: Major
                                                      Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                    return [ 'uploaded-script-svg', $strippedElement ];
                                                        Severity: Major
                                                        Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                          return [ 'uploaded-wrong-setting-svg', $value ];
                                                          Severity: Major
                                                          Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                        return true;
                                                            Severity: Major
                                                            Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                          return true;
                                                              Severity: Major
                                                              Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                        return [ 'status' => self::OK ];
                                                                Severity: Major
                                                                Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                                      return [ 'uploaded-href-unsafe-target-svg', $strippedElement, $attrib, $value ];
                                                                  Severity: Major
                                                                  Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                            return false;
                                                                    Severity: Major
                                                                    Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                      Avoid too many return statements within this method.
                                                                      Open

                                                                                      return true;
                                                                      Severity: Major
                                                                      Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                        Avoid too many return statements within this method.
                                                                        Open

                                                                                return false;
                                                                        Severity: Major
                                                                        Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                          Avoid too many return statements within this method.
                                                                          Open

                                                                                  return false;
                                                                          Severity: Major
                                                                          Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                            Avoid too many return statements within this method.
                                                                            Open

                                                                                            return [ 'uploaded-remote-url-svg', $attrib, $value ];
                                                                            Severity: Major
                                                                            Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                              Avoid too many return statements within this method.
                                                                              Open

                                                                                      return false; // No scripts detected
                                                                              Severity: Major
                                                                              Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                                Avoid too many return statements within this method.
                                                                                Open

                                                                                            return $this->mTitle;
                                                                                Severity: Major
                                                                                Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                                  Avoid too many return statements within this method.
                                                                                  Open

                                                                                              return true;
                                                                                  Severity: Major
                                                                                  Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                                    Avoid too many return statements within this method.
                                                                                    Open

                                                                                                    return [ 'uploaded-setting-href-svg' ];
                                                                                    Severity: Major
                                                                                    Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                                      Avoid too many return statements within this method.
                                                                                      Open

                                                                                                  return $error;
                                                                                      Severity: Major
                                                                                      Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                                        Avoid too many return statements within this method.
                                                                                        Open

                                                                                                return true;
                                                                                        Severity: Major
                                                                                        Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                                          Avoid too many return statements within this method.
                                                                                          Open

                                                                                                      return $this->mTitle;
                                                                                          Severity: Major
                                                                                          Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                                            Avoid too many return statements within this method.
                                                                                            Open

                                                                                                            return [ 'uploaded-href-attribute-svg', $strippedElement, $attrib, $value ];
                                                                                            Severity: Major
                                                                                            Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                                              Avoid too many return statements within this method.
                                                                                              Open

                                                                                                          return $this->mTitle;
                                                                                              Severity: Major
                                                                                              Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                                                Avoid too many return statements within this method.
                                                                                                Open

                                                                                                                return [ 'uploaded-setting-handler-svg', $attrib, $value ];
                                                                                                Severity: Major
                                                                                                Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                                                  Avoid too many return statements within this method.
                                                                                                  Open

                                                                                                                  return [
                                                                                                                      'warning' => 'bad-prefix',
                                                                                                                      'file' => $file,
                                                                                                                      'prefix' => $prefix
                                                                                                                  ];
                                                                                                  Severity: Major
                                                                                                  Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                                                    Avoid too many return statements within this method.
                                                                                                    Open

                                                                                                                    return true;
                                                                                                    Severity: Major
                                                                                                    Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                                                      Avoid too many return statements within this method.
                                                                                                      Open

                                                                                                                  return true;
                                                                                                      Severity: Major
                                                                                                      Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                                                        Avoid too many return statements within this method.
                                                                                                        Open

                                                                                                                        return [ 'uploaded-animate-svg', $strippedElement, $attrib, $value ];
                                                                                                        Severity: Major
                                                                                                        Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                                                          Avoid too many return statements within this method.
                                                                                                          Open

                                                                                                                  return false;
                                                                                                          Severity: Major
                                                                                                          Found in includes/upload/UploadBase.php - About 30 mins to fix

                                                                                                            Avoid too many return statements within this method.
                                                                                                            Open

                                                                                                                            return [
                                                                                                                                'warning' => 'thumb',
                                                                                                                                'file' => $file,
                                                                                                                                'thumbFile' => $file_thb
                                                                                                                            ];
                                                                                                            Severity: Major
                                                                                                            Found in includes/upload/UploadBase.php - About 30 mins to fix

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

                                                                                                                  public function performUpload(
                                                                                                                      $comment, $pageText, $watch, $user, $tags = [], ?string $watchlistExpiry = null
                                                                                                                  ) {
                                                                                                                      $this->getLocalFile()->load( IDBAccessObject::READ_LATEST );
                                                                                                                      $props = $this->mFileProps;
                                                                                                              Severity: Minor
                                                                                                              Found in includes/upload/UploadBase.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 setSessionStatus has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                                              Open

                                                                                                                  public static function setSessionStatus( UserIdentity $user, $statusKey, $value ) {
                                                                                                                      $store = self::getUploadSessionStore();
                                                                                                                      $key = self::getUploadSessionKey( $store, $user, $statusKey );
                                                                                                                      $logger = LoggerFactory::getInstance( 'upload' );
                                                                                                              
                                                                                                              
                                                                                                              Severity: Minor
                                                                                                              Found in includes/upload/UploadBase.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 createFromRequest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                                              Open

                                                                                                                  public static function createFromRequest( &$request, $type = null ) {
                                                                                                                      $type = $type ?: $request->getVal( 'wpSourceType', 'File' );
                                                                                                              
                                                                                                                      if ( !$type ) {
                                                                                                                          return null;
                                                                                                              Severity: Minor
                                                                                                              Found in includes/upload/UploadBase.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