wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function sendResponseHeaders has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    protected function sendResponseHeaders(
        Context $context, $etag, $errors, array $extra = []
    ): void {
        HeaderCallback::warnIfHeadersSent();

Severity: Minor
Found in includes/ResourceLoader/ResourceLoader.php - About 1 hr 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 beginAccountLink has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function beginAccountLink( User $user, array $reqs, $returnToUrl ) {
        $session = $this->request->getSession();
        $session->remove( self::ACCOUNT_LINK_STATE );

        if ( !$this->canLinkAccounts() ) {
Severity: Minor
Found in includes/auth/AuthManager.php - About 1 hr 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 validate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate( $name, $value, array $settings, array $options ) {
        if ( !is_array( $value ) ) {
            // Message used: paramvalidator-notarray
            $this->failure( 'notarray', $name, $value, $settings, $options );
        }
Severity: Minor
Found in includes/ParamValidator/TypeDef/ArrayDef.php - About 1 hr 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 setArrayHookHandler has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function setArrayHookHandler(
        array $callback,
        array $hookHandlersAttr,
        string $name,
        string $path
Severity: Minor
Found in includes/registration/ExtensionProcessor.php - About 1 hr 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 generateUndoEditSummary has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function generateUndoEditSummary( ?RevisionRecord $oldrev, int $undo,
        ?RevisionRecord $undorev, MediaWikiServices $services
    ) {
        // If we just undid one rev, use an autosummary
        $firstrev = $this->revisionStore->getNextRevision( $oldrev );
Severity: Minor
Found in includes/editpage/EditPage.php - About 1 hr 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 extractHooks has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    protected function extractHooks( array $info, string $path ) {
        $extName = $info['name'];
        if ( isset( $info['Hooks'] ) ) {
            $hookHandlersAttr = [];
            foreach ( $info['HookHandlers'] ?? [] as $name => $def ) {
Severity: Minor
Found in includes/registration/ExtensionProcessor.php - About 1 hr 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 addUserConfigPageInfo has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function addUserConfigPageInfo(
        IntroMessageList $messages,
        MessageLocalizer $localizer,
        Title $title,
        Authority $performer,
Severity: Minor
Found in includes/editpage/IntroMessageBuilder.php - About 1 hr 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 writeRevision has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function writeRevision( $row, $slotRows = null ) {
        $rev = $this->getRevisionStore()->newRevisionFromRowAndSlots(
            $row,
            $slotRows,
            0,
Severity: Minor
Found in includes/export/XmlDumpWriter.php - About 1 hr 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 find has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public static function find( $className ): ?string {
        global $wgAutoloadLocalClasses, $wgAutoloadClasses;

        // NOTE: $wgAutoloadClasses is supported for compatibility with old-style extension
        //       registration files.
Severity: Minor
Found in includes/AutoLoader.php - About 1 hr 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 saveRevision has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function saveRevision( CommentStoreComment $summary, int $flags = 0 ) {
        $this->setFlags( $flags );

        if ( $this->wasCommitted() ) {
            throw new RuntimeException(
Severity: Minor
Found in includes/Storage/PageUpdater.php - About 1 hr 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 combineSlotOutput has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function combineSlotOutput( RenderedRevision $rrev, ParserOptions $options, array $hints = [] ) {
        $revision = $rrev->getRevision();
        $slots = $revision->getSlots()->getSlots();

        $withHtml = $hints['generate-html'] ?? true;
Severity: Minor
Found in includes/Revision/RevisionRenderer.php - About 1 hr 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 import has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function import( ImportableUploadRevision $importableRevision ) {
        # Construct a file
        $archiveName = $importableRevision->getArchiveName();
        $localRepo = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo();
        if ( $archiveName ) {
Severity: Minor
Found in includes/import/ImportableUploadRevisionImporter.php - About 1 hr 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 newRevisionFromRowAndSlots has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function newRevisionFromRowAndSlots(
        stdClass $row,
        $slots,
        int $queryFlags = 0,
        ?PageIdentity $page = null,
Severity: Minor
Found in includes/Revision/RevisionStore.php - About 1 hr 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 checkRange has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    protected function checkRange( $value, $name, $origValue, array $settings, array $options ) {
        $min = $settings[self::PARAM_MIN] ?? null;
        $max1 = $settings[self::PARAM_MAX] ?? null;
        $max2 = $settings[self::PARAM_MAX2] ?? $max1;
        $err = false;
Severity: Minor
Found in includes/libs/ParamValidator/TypeDef/NumericDef.php - About 1 hr 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 findNodeIndexForPosition has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function findNodeIndexForPosition( $position, $ring ) {
        $count = count( $ring );
        if ( $count === 0 ) {
            return null;
        }
Severity: Minor
Found in includes/libs/HashRing.php - About 1 hr 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 diff has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function diff( $from_lines, $to_lines ) {
        // Diff and store locally
        $this->diffInternal( $from_lines, $to_lines );

        // Merge edits when possible
Severity: Minor
Found in includes/libs/Diff/DiffEngine.php - About 1 hr 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 deserialize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function deserialize( $json, string $expectedClass = null ) {
        Assert::parameterType( [ 'stdClass', 'array', 'string' ], $json, '$json' );
        Assert::precondition(
            !$expectedClass || is_subclass_of( $expectedClass, JsonDeserializable::class ),
            '$expectedClass parameter must be subclass of JsonDeserializable, got ' . $expectedClass
Severity: Minor
Found in includes/json/JsonCodec.php - About 1 hr 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 doLockByType has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    final protected function doLockByType( array $pathsByType ) {
        $status = StatusValue::newGood();

        $pathsByTypeByBucket = []; // (bucket => type => paths)
        // Get locks that need to be acquired (buckets => locks)...
Severity: Minor
Found in includes/libs/lockmanager/QuorumLockManager.php - About 1 hr 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 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( array $config ) {
        parent::__construct( $config );
        $this->syncChecks = $config['syncChecks'] ?? self::CHECK_SIZE;
        $this->autoResync = $config['autoResync'] ?? false;
        $this->asyncWrites = isset( $config['replication'] ) && $config['replication'] === 'async';
Severity: Minor
Found in includes/libs/filebackend/FileBackendMultiWrite.php - About 1 hr 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 primeFileCache has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    final protected function primeFileCache( array $items ) {
        /** @noinspection PhpUnusedLocalVariableInspection */
        $ps = $this->scopedProfileSection( __METHOD__ . "-{$this->name}" );

        $paths = []; // list of storage paths
Severity: Minor
Found in includes/libs/filebackend/FileBackendStore.php - About 1 hr 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