wikimedia/mediawiki-core

View on GitHub

Showing 11,498 of 11,498 total issues

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

    public function getDefinitionSummary( Context $context ) {
        $summary = parent::getDefinitionSummary( $context );

        $options = [];
        foreach ( [
Severity: Minor
Found in includes/ResourceLoader/FileModule.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 processStyle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function processStyle( $style, $styleLang, $path, Context $context ) {
        $localPath = $this->getLocalPath( $path );
        $remotePath = $this->getRemotePath( $path );

        if ( $styleLang === 'less' ) {
Severity: Minor
Found in includes/ResourceLoader/FileModule.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 extractBasePaths has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function extractBasePaths(
        array $options = [],
        $localBasePath = null,
        $remoteBasePath = null
    ) {
Severity: Minor
Found in includes/ResourceLoader/FileModule.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 extractMessagesDirs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function extractMessagesDirs( $dir, array $info ) {
        if ( isset( $info['MessagesDirs'] ) ) {
            foreach ( $info['MessagesDirs'] as $name => $files ) {
                foreach ( (array)$files as $file ) {
                    $this->globals["wgMessagesDirs"][$name][] = "$dir/$file";
Severity: Minor
Found in includes/registration/ExtensionProcessor.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 setUsernameBitfields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function setUsernameBitfields( $name, $userId, $op, IDatabase $dbw = null ) {
        if ( !$userId || ( $op !== '|' && $op !== '&' ) ) {
            return false;
        }
        if ( !$dbw instanceof IDatabase ) {
Severity: Minor
Found in includes/revisiondelete/RevisionDeleteUser.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 checkSettings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function checkSettings( string $name, $settings, array $options, array $ret ): array {
        $ret = parent::checkSettings( $name, $settings, $options, $ret );

        $ret['allowedKeys'] = array_merge( $ret['allowedKeys'], [
            self::PARAM_EXTRA_NAMESPACES,
Severity: Minor
Found in includes/ParamValidator/TypeDef/NamespaceDef.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 limits has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function limits( array $limits ): Command {
        if ( !isset( $limits['walltime'] ) && isset( $limits['time'] ) ) {
            // Emulate the behavior of old wfShellExec() where walltime fell back on time
            // if the latter was overridden and the former wasn't
            $limits['walltime'] = $limits['time'];
Severity: Minor
Found in includes/shell/Command.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 providerChangeAuthenticationData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function providerChangeAuthenticationData( AuthenticationRequest $req ) {
        $username = $req->username !== null ?
            $this->userNameUtils->getCanonical( $req->username, UserRigorOptions::RIGOR_USABLE )
            : false;
        if ( $username === false ) {
Severity: Minor
Found in includes/auth/LocalPasswordPrimaryAuthenticationProvider.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 extractSkins has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function extractSkins( $dir, array $info ) {
        if ( isset( $info['ValidSkinNames'] ) ) {
            foreach ( $info['ValidSkinNames'] as $skinKey => $data ) {
                if ( isset( $data['args'][0] ) ) {
                    $templateDirectory = $data['args'][0]['templateDirectory'] ?? 'templates';
Severity: Minor
Found in includes/registration/ExtensionProcessor.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 saveToCache has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function saveToCache( BagOStuff $cache, array $data ) {
        global $wgDevelopmentWarnings;
        if ( $data['warnings'] && $wgDevelopmentWarnings ) {
            // If warnings were shown, don't cache it
            return;
Severity: Minor
Found in includes/registration/ExtensionRegistry.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( ShellboxClientFactory $shellboxClientFactory,
        array $limits, $cgroup, $restrictionMethod
    ) {
        $this->shellboxClientFactory = $shellboxClientFactory;
        $this->limits = $limits;
Severity: Minor
Found in includes/shell/CommandFactory.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 getMWLogo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getMWLogo() {
        global $wgResourceBasePath;
        $suffix = "/resources/assets/mediawiki.png";
        if ( $wgResourceBasePath !== null ) {
            // We are early in setup, so we can't rely on this.
Severity: Minor
Found in includes/registration/MissingExtensionException.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 forcePrimaryAuthenticationProviders has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function forcePrimaryAuthenticationProviders( array $providers, $why ) {
        wfDeprecated( __METHOD__, '1.43' );

        $this->logger->warning( "Overriding AuthManager primary authn because $why" );

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

    private function displayViewSourcePage( Content $content, string $errorMessage ): void {
        $out = $this->context->getOutput();
        $this->getHookRunner()->onEditPage__showReadOnlyForm_initial( $this, $out );

        $out->setRobotPolicy( 'noindex,nofollow' );
Severity: Minor
Found in includes/editpage/EditPage.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 getCheckboxesDefinitionForWatchlist has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getCheckboxesDefinitionForWatchlist( $watch, $watchexpiry ): array {
        $fieldDefs = [
            'wpWatchthis' => [
                'id' => 'wpWatchthis',
                'label-message' => 'watchthis',
Severity: Minor
Found in includes/editpage/EditPage.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 populateUser has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function populateUser( $user ) {
        if ( $this->email !== null && $this->email !== '' ) {
            if ( !Sanitizer::validateEmail( $this->email ) ) {
                return StatusValue::newFatal( 'invalidemailaddress' );
            }
Severity: Minor
Found in includes/auth/UserDataAuthenticationRequest.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 beginPrimaryAuthentication has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function beginPrimaryAuthentication( array $reqs ) {
        $req = AuthenticationRequest::getRequestByClass( $reqs, PasswordAuthenticationRequest::class );
        if ( !$req || $req->username === null || $req->password === null ) {
            return AuthenticationResponse::newAbstain();
        }
Severity: Minor
Found in includes/auth/TemporaryPasswordPrimaryAuthenticationProvider.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 setPasswordResetFlag has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function setPasswordResetFlag( $username, Status $status, $data = null ) {
        $reset = $this->getPasswordResetData( $username, $data );

        if ( !$reset && $this->config->get( MainConfigNames::InvalidPasswordReset ) &&
        !$status->isGood() ) {
Severity: Minor
Found in includes/auth/AbstractPasswordPrimaryAuthenticationProvider.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 function getContentType() {
        if ( $this->allowOutput ) {
            foreach ( headers_list() as $header ) {
                if ( preg_match( '#^content-type: (\w+/\w+);?#i', $header, $m ) ) {
                    return $m[1];
Severity: Minor
Found in includes/profiler/Profiler.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 getUserForPreview has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getUserForPreview() {
        if ( $this->savedTempUser ) {
            return $this->savedTempUser;
        } elseif ( $this->unsavedTempUser ) {
            return $this->unsavedTempUser;
Severity: Minor
Found in includes/editpage/EditPage.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