wikimedia/mediawiki-core

View on GitHub

Showing 11,498 of 11,498 total issues

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

function getNearestOverflowAncestor(node) {
  const parentNode = getParentNode(node);
  if (isLastTraversableNode(parentNode)) {
    return node.ownerDocument ? node.ownerDocument.body : node.body;
  }
Severity: Minor
Found in resources/lib/codex/codex.js - 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 getWatchedItemsForUser has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getWatchedItemsForUser( UserIdentity $user, array $options = [] ) {
        if ( !$user->isRegistered() ) {
            // TODO: should this just return an empty array or rather complain loud at this point
            // as e.g. ApiBase::getWatchlistUser does?
            return [];
Severity: Minor
Found in includes/watchlist/WatchedItemQueryService.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

    public function run() {
        $updateRowsPerQuery = MediaWikiServices::getInstance()->getMainConfig()->get(
            MainConfigNames::UpdateRowsPerQuery );
        $userId = $this->params['userId'];
        $maxWatchlistId = $this->params['maxWatchlistId'];
Severity: Minor
Found in includes/watchlist/ClearUserWatchlistJob.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 checkSpecialsAndNSPermissions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkSpecialsAndNSPermissions(
        $action,
        UserIdentity $user,
        PermissionStatus $status,
        $rigor,
Severity: Minor
Found in includes/Permissions/PermissionManager.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 getGrantsWikiText has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getGrantsWikiText( $grantsFilter, $lang = null ): string {
        if ( is_string( $lang ) ) {
            $lang = $this->languageFactory->getLanguage( $lang );
        } elseif ( $lang === null ) {
            $lang = $this->contentLanguage;
Severity: Minor
Found in includes/Permissions/GrantsLocalization.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 getVisitingWatchersCondition has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getVisitingWatchersCondition(
        IReadableDatabase $db,
        array $targetsWithVisitThresholds
    ): string {
        $missingTargets = [];
Severity: Minor
Found in includes/watchlist/WatchedItemStore.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 getGrantDescriptionsWithClasses has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getGrantDescriptionsWithClasses( array $grants, $lang = null ): array {
        $riskGroupsByGrant = $this->grantsInfo->getRiskGroupsByGrant( 'unknown' );
        $grantDescriptions = $this->getGrantDescriptions( $grants, $lang );
        $results = [];
        foreach ( $grantDescriptions as $grant => $description ) {
Severity: Minor
Found in includes/Permissions/GrantsLocalization.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 checkPermissionHooks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkPermissionHooks(
        $action,
        User $user,
        PermissionStatus $status,
        $rigor,
Severity: Minor
Found in includes/Permissions/PermissionManager.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 uncacheUser has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function uncacheUser( UserIdentity $user ) {
        $this->statsFactory->getCounter( 'WatchedItemStore_uncacheUser_total' )
            ->copyToStatsdAt( 'WatchedItemStore.uncacheUser' )
            ->increment();
        $uncacheUserItemsTotal = $this->statsFactory->getCounter( 'WatchedItemStore_uncacheUser_items_total' )
Severity: Minor
Found in includes/watchlist/WatchedItemStore.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 duplicateEntry has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function duplicateEntry( $oldTarget, $newTarget ) {
        $dbw = $this->lbFactory->getPrimaryDatabase();
        $result = $this->fetchWatchedItemsForPage( $dbw, $oldTarget );
        $newNamespace = $newTarget->getNamespace();
        $newDBkey = $newTarget->getDBkey();
Severity: Minor
Found in includes/watchlist/WatchedItemStore.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 persistSession has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function persistSession( SessionBackend $session, WebRequest $request ) {
        if ( $this->sessionCookieName === null ) {
            return;
        }

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

    public function getDuplicates() {
        $this->loadFile();
        if ( $this->mDupes !== null ) {
            return $this->mDupes;
        }
Severity: Minor
Found in includes/page/WikiFilePage.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 getProviders has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getProviders() {
        if ( $this->sessionProviders === null ) {
            $this->sessionProviders = [];
            $objectFactory = MediaWikiServices::getInstance()->getObjectFactory();
            foreach ( $this->config->get( MainConfigNames::SessionProviders ) as $spec ) {
Severity: Minor
Found in includes/session/SessionManager.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 detectDeprecatedConfig has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function detectDeprecatedConfig(): array {
        $config = $this->getConfig();
        $keys = $this->getDefinedConfigKeys();
        $deprecated = [];

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

    public function loadWikiFarmSettings() {
        $config = $this->settingsBuilder->getConfig();

        $farmDir = $config->get( MainConfigNames::WikiFarmSettingsDirectory );
        $farmExt = $config->get( MainConfigNames::WikiFarmSettingsExtension );
Severity: Minor
Found in includes/Settings/WikiFarmSettingsLoader.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 getStrategyForType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function getStrategyForType( $type ) {
        if ( is_array( $type ) ) {
            if ( in_array( 'array', $type ) ) {
                $type = 'array';
            } elseif ( in_array( 'object', $type ) ) {
Severity: Minor
Found in includes/Settings/Config/ConfigSchemaAggregator.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 jsonToPhpDoc has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function jsonToPhpDoc( $jsonSchemaType ) {
        static $phpTypes = [
            'array' => 'array',
            'object' => 'array', // could be optional
            'number' => 'float',
Severity: Minor
Found in includes/Settings/Source/JsonSchemaTrait.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 setForceHTTPSCookie has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function setForceHTTPSCookie( $set, ?SessionBackend $backend, WebRequest $request ) {
        if ( $this->getConfig()->get( MainConfigNames::ForceHTTPS ) ) {
            // No need to send a cookie if the wiki is always HTTPS (T256095)
            return;
        }
Severity: Minor
Found in includes/session/CookieSessionProvider.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 resetId has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function resetId() {
        if ( $this->provider->persistsSessionId() ) {
            $oldId = (string)$this->id;
            $restart = $this->usePhpSessionHandling && $oldId === session_id() &&
                PHPSessionHandler::isEnabled();
Severity: Minor
Found in includes/session/SessionBackend.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 handleRequest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function handleRequest( $subPage, WebRequest $request, OutputPage $output ) {
        // No matter what: The response is always public
        $output->getRequest()->response()->header( 'Access-Control-Allow-Origin: *' );

        if ( !$this->canHandleRequest( $subPage, $request ) ) {
Severity: Minor
Found in includes/linkeddata/PageDataRequestHandler.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