wikimedia/mediawiki-core

View on GitHub

Showing 9,711 of 11,779 total issues

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

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

    public function __construct( $title, $id = 0, $key = '', $sha1 = '' ) {
        $this->id = -1;
        $this->title = null;
        $this->name = false;
        $this->group = 'deleted'; // needed for direct use of constructor
Severity: Minor
Found in includes/filerepo/file/ArchivedFile.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 validateParams has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function validateParams( array $paramSettings ) {
        $validatedParams = [];
        foreach ( $paramSettings as $name => $settings ) {
            try {
                $source = $settings[Handler::PARAM_SOURCE] ?? 'unspecified';
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

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

    protected function assertDomainIsCorrect( $domain ): void {
        // We are cutting some corners here (IDN, non-ASCII casing)
        // since domain name support is provisional.
        // TODO use a proper validator instead
        $server = RequestContext::getMain()->getConfig()->get( MainConfigNames::Server );
Severity: Minor
Found in includes/Rest/Handler/ParsoidHandler.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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $searchEngine = $this->createSearchEngine();
        $pageInfos = $this->doSearch( $searchEngine );

        // We can only pass validated "real" PageIdentities to our hook handlers below
Severity: Minor
Found in includes/Rest/Handler/SearchHandler.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 throwHttpExceptionForActionModuleError has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function throwHttpExceptionForActionModuleError( IApiMessage $msg, $statusCode = 400 ) {
        $code = $msg->getApiCode();

        if ( $code === 'protectedpage' ) {
            throw new LocalizedHttpException( $this->makeMessageValue( $msg ), 403 );
Severity: Minor
Found in includes/Rest/Handler/EditHandler.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 seek has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function seek( $offset, $whence = SEEK_SET ) {
        switch ( $whence ) {
            case SEEK_SET:
                $this->offset = $offset;
                break;
Severity: Minor
Found in includes/Rest/StringStream.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 match has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function match( $path ) {
        $parts = explode( '/', $path );
        $length = count( $parts );
        if ( !isset( $this->treesByLength[$length] ) ) {
            return false;
Severity: Minor
Found in includes/Rest/PathTemplateMatcher/PathMatcher.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 getContentType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getContentType(
        string $format, ?string $contentVersion = null
    ): string {
        if ( $format !== self::FORMAT_WIKITEXT && !$contentVersion ) {
            throw new InvalidArgumentException( '$contentVersion is required for this format' );
Severity: Minor
Found in includes/Rest/Handler/Helper/ParsoidFormatHelper.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