wikimedia/mediawiki-core

View on GitHub
includes/upload/UploadFromChunks.php

Summary

Maintainability
C
1 day
Test Coverage

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

    public function concatenateChunks() {
        $oldFileKey = $this->mFileKey;
        $chunkIndex = $this->getChunkIndex();
        $this->logger->debug(
            __METHOD__ . ' concatenate {totalChunks} chunks: {offset} inx: {curIndex}',
Severity: Major
Found in includes/upload/UploadFromChunks.php - About 4 hrs to fix

    File UploadFromChunks.php has 307 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    use MediaWiki\Logger\LoggerFactory;
    use MediaWiki\MediaWikiServices;
    use MediaWiki\Request\WebRequestUpload;
    Severity: Minor
    Found in includes/upload/UploadFromChunks.php - About 3 hrs to fix

      Method addChunk has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function addChunk( $chunkPath, $chunkSize, $offset ) {
              // Get the offset before we add the chunk to the file system
              $preAppendOffset = $this->getOffset();
      
              if ( $preAppendOffset + $chunkSize > $this->getMaxUploadSize() ) {
      Severity: Minor
      Found in includes/upload/UploadFromChunks.php - About 1 hr to fix

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

            public function addChunk( $chunkPath, $chunkSize, $offset ) {
                // Get the offset before we add the chunk to the file system
                $preAppendOffset = $this->getOffset();
        
                if ( $preAppendOffset + $chunkSize > $this->getMaxUploadSize() ) {
        Severity: Minor
        Found in includes/upload/UploadFromChunks.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 concatenateChunks has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function concatenateChunks() {
                $oldFileKey = $this->mFileKey;
                $chunkIndex = $this->getChunkIndex();
                $this->logger->debug(
                    __METHOD__ . ' concatenate {totalChunks} chunks: {offset} inx: {curIndex}',
        Severity: Minor
        Found in includes/upload/UploadFromChunks.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

        Avoid too many return statements within this method.
        Open

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

          There are no issues that match your filters.

          Category
          Status