wikimedia/mediawiki-core

View on GitHub

Showing 11,498 of 11,498 total issues

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

    public function getAvailableLanguages( File $file ) {
        $langList = [];
        $metadata = $this->validateMetadata( $file->getMetadataArray() );
        if ( isset( $metadata['translations'] ) ) {
            foreach ( $metadata['translations'] as $lang => $langType ) {
Severity: Minor
Found in includes/media/SvgHandler.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 internalUserTimeAndDate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function internalUserTimeAndDate( $type, $ts, UserIdentity $user, array $options ) {
        $ts = wfTimestamp( TS_MW, $ts );
        $options += [ 'timecorrection' => true, 'format' => true ];
        if ( $options['timecorrection'] !== false ) {
            if ( $options['timecorrection'] === true ) {
Severity: Minor
Found in includes/language/Language.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 convIPTCHelper has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function convIPTCHelper( $data, $charset ) {
        if ( $charset ) {
            AtEase::suppressWarnings();
            $data = iconv( $charset, "UTF-8//IGNORE", $data );
            AtEase::restoreWarnings();
Severity: Minor
Found in includes/media/IPTC.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 getLongDesc has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getLongDesc( $image ) {
        global $wgLang;
        $original = parent::getLongDesc( $image );

        $metadata = $image->getMetadataArray();
Severity: Minor
Found in includes/media/PNGHandler.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 resolveMultivalueValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function resolveMultivalueValue( $value ) {
        if ( !is_array( $value ) ) {
            return $value;
        }
        if ( isset( $value['_type'] ) && $value['_type'] === 'lang' ) {
Severity: Minor
Found in includes/media/FormatMetadata.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 wfMsgReplaceArgs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function wfMsgReplaceArgs( $message, $args ) {
    # Fix windows line-endings
    # Some messages are split with explode("\n", $msg)
    $message = str_replace( "\r", '', $message );

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

    public function getLimitOffsetForUser( UserIdentity $user, $deflimit = 50, $optionname = 'rclimit' ) {
        $limit = $this->getInt( 'limit', 0 );
        if ( $limit < 0 ) {
            $limit = 0;
        }
Severity: Minor
Found in includes/Request/WebRequest.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 getSizeAndMetadata has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getSizeAndMetadata( $state, $filename ) {
        $header = self::getXCFMetaData( $filename );
        $metadata = [];
        if ( $header ) {
            // Try to be consistent with the names used by PNG files.
Severity: Minor
Found in includes/media/XCFHandler.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 debug has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function debug( $in, $fname, $action = null ) {
        if ( !$this->log ) {
            return;
        }
        $type = gettype( $in );
Severity: Minor
Found in includes/media/Exif.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 readPHPFile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function readPHPFile( $fileName, $fileType ) {
        $serialize = $fileType === 'core';
        if ( !isset( $this->fileCache[$fileName][$fileType] ) ) {
            $data = parent::readPHPFile( $fileName, $fileType );

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

    protected function normaliseParamsInternal( $image, $params ) {
        $svgMaxSize = MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::SVGMaxSize );

        # Don't make an image bigger than wgMaxSVGSize on the smaller side
        if ( $params['physicalWidth'] <= $params['physicalHeight'] ) {
Severity: Minor
Found in includes/media/SvgHandler.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 parseFormDjvu has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function parseFormDjvu( $line ) {
        $parentLevel = strspn( $line, ' ' );
        $line = strtok( "\n" );
        # Find INFO
        while ( $line !== false ) {
Severity: Minor
Found in includes/media/DjVuImage.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 swapICCProfile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function swapICCProfile( $filepath, array $colorSpaces,
        array $oldProfileStrings, $profileFilepath
    ) {
        $exiftool = MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::Exiftool );

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

    public function fetchExtendedMetadata( File $file ) {
        $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();

        // If revision deleted, exit immediately
        if ( $file->isDeleted( File::DELETED_FILE ) ) {
Severity: Minor
Found in includes/media/FormatMetadata.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 getCORSSources has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getCORSSources() {
        $additionalUrls = [];
        $CORSSources = $this->mwConfig->get( MainConfigNames::CrossSiteAJAXdomains );
        foreach ( $CORSSources as $source ) {
            if ( strpos( $source, '?' ) !== false ) {
Severity: Minor
Found in includes/Request/ContentSecurityPolicy.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 wfDebugBacktrace has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function wfDebugBacktrace( $limit = 0 ) {
    static $disabled = null;

    if ( $disabled === null ) {
        $disabled = !function_exists( 'debug_backtrace' );
Severity: Minor
Found in includes/GlobalFunctions.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 registerFiltersFromDefinitions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function registerFiltersFromDefinitions( array $definition ) {
        $autoFillPriority = -1;
        foreach ( $definition as $groupDefinition ) {
            if ( !isset( $groupDefinition['priority'] ) ) {
                $groupDefinition['priority'] = $autoFillPriority;
Severity: Minor
Found in includes/specialpage/ChangesListSpecialPage.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 wfMergeErrorArrays has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function wfMergeErrorArrays( ...$args ) {
    $out = [];
    foreach ( $args as $errors ) {
        foreach ( $errors as $params ) {
            $originalParams = $params;
Severity: Minor
Found in includes/GlobalFunctions.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 addTabIndex has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function addTabIndex( &$formDescriptor ) {
        $i = 1;
        foreach ( $formDescriptor as &$definition ) {
            $class = false;
            if ( array_key_exists( 'class', $definition ) ) {
Severity: Minor
Found in includes/specialpage/AuthManagerSpecialPage.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( Installer $installer ) {
        $this->installer = $installer;

        $this->extensions = $installer->getVar( '_Extensions' );
        $this->skins = $installer->getVar( '_Skins' );
Severity: Minor
Found in includes/installer/LocalSettingsGenerator.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