wikimedia/mediawiki-core

View on GitHub

Showing 11,461 of 11,461 total issues

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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function run( DeferrableUpdate $update ): ?Throwable {
        $logger = LoggerFactory::getInstance( 'DeferredUpdates' );

        $type = get_class( $update )
            . ( $update instanceof DeferrableCallback ? '_' . $update->getOrigin() : '' );
Severity: Minor
Found in includes/deferred/DeferredUpdates.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 doWrites has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doWrites() {
        $db = $this->getDB();
        $table = $this->getTableName();
        $domainId = $db->getDomainID();
        $batchSize = $this->getBatchSize();
Severity: Minor
Found in includes/deferred/LinksUpdate/LinksTable.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 applyCacheControl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function applyCacheControl( ResponseInterface $response ) {
        // NOTE: keep this consistent with the logic in OutputPage::sendCacheControl

        // If the response sets cookies, it must not be cached in proxies.
        // If there's an active cookie-based session (logged-in user or anonymous user with
Severity: Minor
Found in includes/Rest/Handler.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 getHandler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getHandler( $name ) {
        if ( !isset( $this->singletons['handlers'][$name] ) ) {
            $spec = $this->config['handlers'][$name];
            /** @var HandlerInterface $handler */
            $handler = ObjectFactory::getObjectFromSpec( $spec );
Severity: Minor
Found in includes/debug/logger/MonologSpi.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 parseBodyData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function parseBodyData( RequestInterface $request ): ?array {
        // Parse the body based on its content type
        $contentType = $request->getBodyType();

        // HACK: If the Handler uses a custom BodyValidator, the
Severity: Minor
Found in includes/Rest/Handler.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 tryOpportunisticExecute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function tryOpportunisticExecute(): bool {
        // Leave execution up to the current loop if an update is already in progress
        // or if updates are explicitly disabled
        if ( self::getRecursiveExecutionStackDepth()
            || self::$preventOpportunisticUpdates
Severity: Minor
Found in includes/deferred/DeferredUpdates.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 loadAndLazyInit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected static function loadAndLazyInit() {
        $config = MediaWikiServices::getInstance()->getMainConfig();

        $lb = self::getLB();
        $dbr = $lb->getConnection( DB_REPLICA );
Severity: Minor
Found in includes/SiteStats/SiteStats.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 getIndexedUrlsNonReversed has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getIndexedUrlsNonReversed( $urls ) {
        $newLinks = [];
        foreach ( $urls as $url ) {
            $indexes = self::makeIndexes( $url, false );
            if ( !$indexes ) {
Severity: Minor
Found in includes/ExternalLinks/LinkFilter.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 tidy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function tidy( $text, ?callable $textProcessor = null ) {
        $traceCallback = static function ( $msg ) {
            wfDebug( "RemexHtml: $msg" );
        };
        $formatter = new RemexCompatFormatter( [ 'textProcessor' => $textProcessor ] );
Severity: Minor
Found in includes/tidy/RemexDriver.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 reverseDomain has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function reverseDomain( $domain ) {
        if ( substr( $domain, 0, 3 ) === 'V6.' ) {
            $ipv6 = str_replace( '.', ':', trim( substr( $domain, 3 ), '.' ) );
            if ( IPUtils::isValid( $ipv6 ) ) {
                return '[' . $ipv6 . ']';
Severity: Minor
Found in includes/ExternalLinks/LinkFilter.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 fillParserOutput has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function fillParserOutput(
        Content $content,
        ContentParseParams $cpoParams,
        ParserOutput &$output
    ) {
Severity: Minor
Found in includes/content/TextContentHandler.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 siteFromDB has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function siteFromDB( $wiki ) {
        // Allow override
        $def = $this->getWikiParams( $wiki );
        if ( $def['suffix'] !== null && $def['lang'] !== null ) {
            return [ $def['suffix'], $def['lang'] ];
Severity: Minor
Found in includes/config/SiteConfiguration.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 deprecationHelperGetPropertyOwner has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function deprecationHelperGetPropertyOwner( $property ) {
        // Returning false is a non-error path and should avoid slow checks like reflection.
        // Use array cast hack instead.
        $obfuscatedProps = array_keys( (array)$this );
        $obfuscatedPropTail = "\0$property";
Severity: Minor
Found in includes/debug/DeprecationHelper.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 checkPasswordCannotMatchDefaults has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function checkPasswordCannotMatchDefaults( $policyVal, UserIdentity $user, $password ) {
        static $blockedLogins = [
            // r75589
            'Useruser' => 'Passpass',
            'Useruser1' => 'Passpass1',
Severity: Minor
Found in includes/password/PasswordPolicyChecks.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 makeRedirectContent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function makeRedirectContent( Title $destination, $text = '' ) {
        $optionalColon = '';

        if ( $destination->getNamespace() === NS_CATEGORY ) {
            $optionalColon = ':';
Severity: Minor
Found in includes/content/WikitextContentHandler.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 crypt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function crypt( string $password ): void {
        $lastHash = $password;
        foreach ( $this->config['types'] as $i => $type ) {
            // Construct pseudo-hash based on params and arguments
            /** @var ParameterizedPassword $passObj */
Severity: Minor
Found in includes/password/LayeredParameterizedPassword.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 parseHash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function parseHash( ?string $hash ): void {
        parent::parseHash( $hash );

        if ( $hash === null ) {
            $this->params = $this->getDefaultParams();
Severity: Minor
Found in includes/password/ParameterizedPassword.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 getDataForSearchIndex has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getDataForSearchIndex(
        WikiPage $page,
        ParserOutput $parserOutput,
        SearchEngine $engine,
        ?RevisionRecord $revision = null
Severity: Minor
Found in includes/content/FileContentHandler.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