wikimedia/mediawiki-core

View on GitHub
includes/upload/UploadStash.php

Summary

Maintainability
C
1 day
Test Coverage

Method stashFile has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function stashFile( $path, $sourceType = null, $fileProps = null ) {
        if ( !is_file( $path ) ) {
            wfDebug( __METHOD__ . " tried to stash file at '$path', but it doesn't exist" );
            throw new UploadStashBadPathException(
                wfMessage( 'uploadstash-bad-path' )
Severity: Major
Found in includes/upload/UploadStash.php - About 3 hrs to fix

    File UploadStash.php has 284 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Temporary storage for uploaded files.
     *
     * This program is free software; you can redistribute it and/or modify
    Severity: Minor
    Found in includes/upload/UploadStash.php - About 2 hrs to fix

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

          public function getFile( $key, $noAuth = false ) {
              if ( !preg_match( self::KEY_FORMAT_REGEX, $key ) ) {
                  throw new UploadStashBadPathException(
                      wfMessage( 'uploadstash-bad-path-bad-format', $key )
                  );
      Severity: Minor
      Found in includes/upload/UploadStash.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 getFile has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getFile( $key, $noAuth = false ) {
              if ( !preg_match( self::KEY_FORMAT_REGEX, $key ) ) {
                  throw new UploadStashBadPathException(
                      wfMessage( 'uploadstash-bad-path-bad-format', $key )
                  );
      Severity: Minor
      Found in includes/upload/UploadStash.php - About 1 hr to fix

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

            public function stashFile( $path, $sourceType = null, $fileProps = null ) {
                if ( !is_file( $path ) ) {
                    wfDebug( __METHOD__ . " tried to stash file at '$path', but it doesn't exist" );
                    throw new UploadStashBadPathException(
                        wfMessage( 'uploadstash-bad-path' )
        Severity: Minor
        Found in includes/upload/UploadStash.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

        There are no issues that match your filters.

        Category
        Status