wikimedia/mediawiki-core

View on GitHub

Showing 11,779 of 11,779 total issues

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

    public function createProtectDescription( array $details ) {
        $protectDescription = '';

        foreach ( $details as $param ) {
            $expiryText = $this->formatExpiry( $param['expiry'] );
Severity: Minor
Found in includes/logging/ProtectLogFormatter.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 extractThumbRequestInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function extractThumbRequestInfo( $thumbRel ) {
        $repo = $this->getServiceContainer()->getRepoGroup()->getLocalRepo();

        $hashDirReg = $subdirReg = '';
        $hashLevels = $repo->getHashLevels();
Severity: Minor
Found in includes/filerepo/Thumbnail404EntryPoint.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 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 getAllowedHosts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function getAllowedHosts(): array {
        $config = MediaWikiServices::getInstance()->getMainConfig();
        $domains = $config->get( MainConfigNames::CopyUploadsDomains );

        if ( $config->get( MainConfigNames::CopyUploadAllowOnWikiDomainConfig ) ) {
Severity: Minor
Found in includes/upload/UploadFromUrl.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

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

    private function salvage( self $other ) {
        foreach ( $this->getServiceNames() as $name ) {
            // The service could be new in the new instance and not registered in the
            // other instance (e.g. an extension that was loaded after the instantiation of
            // the other instance. Skip this service in this case. See T143974
Severity: Minor
Found in includes/MediaWikiServices.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 newFile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function newFile( $title, $time = false ) {
        $title = File::normalizeTitle( $title );
        if ( !$title ) {
            return null;
        }
Severity: Minor
Found in includes/filerepo/FileRepo.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 mungeOpPaths has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function mungeOpPaths( array $ops ) {
        // Ops that use 'src' and do not mutate core file data there
        static $srcRefOps = [ 'store', 'copy', 'describe' ];
        foreach ( $ops as &$op ) {
            if ( isset( $op['src'] ) && in_array( $op['op'], $srcRefOps ) ) {
Severity: Minor
Found in includes/filerepo/FileBackendDBRepoWrapper.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 removeNonexistentFiles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function removeNonexistentFiles( $triplets ) {
        $files = [];

        foreach ( $triplets as $file ) {
            $files[$file[0]] = $file[0];
Severity: Minor
Found in includes/filerepo/file/LocalFileMoveBatch.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 loadExtraFromDB has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function loadExtraFromDB() {
        if ( !$this->title ) {
            return; // Avoid hard failure when the file does not exist. T221812
        }

Severity: Minor
Found in includes/filerepo/file/LocalFile.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 purgeThumbList has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function purgeThumbList( $dir, $files ) {
        $fileListDebug = strtr(
            var_export( $files, true ),
            [ "\n" => '' ]
        );
Severity: Minor
Found in includes/filerepo/file/LocalFile.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 generateBucketsIfNeeded has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function generateBucketsIfNeeded( $params, $flags = 0 ) {
        if ( !$this->repo
            || !isset( $params['physicalWidth'] )
            || !isset( $params['physicalHeight'] )
        ) {
Severity: Minor
Found in includes/filerepo/file/File.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 deleteBatch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function deleteBatch( array $sourceDestPairs ) {
        $this->assertWritableRepo(); // fail out if read-only

        // Try creating directories
        $this->initZones( [ 'public', 'deleted' ] );
Severity: Minor
Found in includes/filerepo/FileRepo.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 load has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function load( $flags = 0 ) {
        if ( !$this->dataLoaded ) {
            if ( $flags & IDBAccessObject::READ_LATEST ) {
                $this->loadFromDB( $flags );
            } else {
Severity: Minor
Found in includes/filerepo/file/LocalFile.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 getThumbnails has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getThumbnails( $archiveName = false ) {
        if ( $archiveName ) {
            $dir = $this->getArchiveThumbPath( $archiveName );
        } else {
            $dir = $this->getThumbPath();
Severity: Minor
Found in includes/filerepo/file/LocalFile.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 prerenderThumbnails has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function prerenderThumbnails() {
        $uploadThumbnailRenderMap = MediaWikiServices::getInstance()
            ->getMainConfig()->get( MainConfigNames::UploadThumbnailRenderMap );

        $jobs = [];
Severity: Minor
Found in includes/filerepo/file/LocalFile.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 getZoneUrl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getZoneUrl( $zone, $ext = null ) {
        if ( in_array( $zone, [ 'public', 'thumb', 'transcoded' ] ) ) {
            // standard public zones
            if ( $ext !== null && isset( $this->zones[$zone]['urlsByExt'][$ext] ) ) {
                // custom URL for extension/zone
Severity: Minor
Found in includes/filerepo/FileRepo.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 getDescriptionRenderUrl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getDescriptionRenderUrl( $name, $lang = null ) {
        $query = 'action=render';
        if ( $lang !== null ) {
            $query .= '&uselang=' . urlencode( $lang );
        }
Severity: Minor
Found in includes/filerepo/FileRepo.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 validateBodyParams has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function validateBodyParams( array $paramSettings ) {
        $validatedParams = [];
        foreach ( $paramSettings as $name => $settings ) {
            $source = $settings[Handler::PARAM_SOURCE] ?? 'body';
            if ( $source !== 'body' ) {
Severity: Minor
Found in includes/Rest/Validator/Validator.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

Severity
Category
Status
Source
Language