wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

    private function displayPreviewArea( string $previewOutput, bool $isOnTop ): void {
        $attribs = [ 'id' => 'wikiPreview' ];
        if ( $isOnTop ) {
            $attribs['class'] = 'ontop';
        }
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 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 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 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 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/AbstractTemporaryPasswordPrimaryAuthenticationProvider.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 beginPrimaryAccountCreation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function beginPrimaryAccountCreation( $user, $creator, array $reqs ) {
        /** @var TemporaryPasswordAuthenticationRequest $req */
        $req = AuthenticationRequest::getRequestByClass(
            $reqs, TemporaryPasswordAuthenticationRequest::class
        );
Severity: Minor
Found in includes/auth/AbstractTemporaryPasswordPrimaryAuthenticationProvider.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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( &$sink, $param ) {
        parent::__construct( $sink );

        $constants = [
            "NS_MAIN"           => NS_MAIN,
Severity: Minor
Found in includes/export/DumpNamespaceFilter.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 getSlotRowBatch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getSlotRowBatch( $results, &$carry = null ) {
        $slotRows = [];
        $prev = null;

        if ( $carry ) {
Severity: Minor
Found in includes/export/WikiExporter.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 checkConstraint has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function checkConstraint(): string {
        $defaultMessageText = $this->title->getDefaultMessageText();
        if ( $this->title->getNamespace() === NS_MEDIAWIKI && $defaultMessageText !== false ) {
            $defaultText = $defaultMessageText;
        } else {
Severity: Minor
Found in includes/editpage/Constraint/DefaultTextConstraint.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 pagesByRange has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function pagesByRange( $start, $end, $orderRevs ) {
        if ( $orderRevs ) {
            $condition = 'rev_page >= ' . intval( $start );
            if ( $end ) {
                $condition .= ' AND rev_page < ' . intval( $end );
Severity: Minor
Found in includes/export/WikiExporter.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 addEditNotices has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function addEditNotices(
        IntroMessageList $messages,
        MessageLocalizer $localizer,
        Title $title,
        ?RevisionRecord $revRecord
Severity: Minor
Found in includes/editpage/IntroMessageBuilder.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