wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function submit has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public function submit() {
        $this->parent->setVarsFromRequest( [ '_RightsProfile', '_LicenseCode',
            'wgEnableEmail', 'wgPasswordSender', 'wgEnableUploads',
            '_Logo1x', '_LogoWordmark', '_LogoTagline', '_LogoIcon',
            'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist',
Severity: Minor
Found in includes/installer/WebInstallerOptions.php - About 3 hrs 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 execute has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $pages = $this->getPageSet()->getGoodPages();
        if ( $pages === [] ) {
            return;
        }
Severity: Minor
Found in includes/api/ApiQueryIWLinks.php - About 3 hrs 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 handleCORS has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    protected function handleCORS() {
        $originParam = $this->getParameter( 'origin' ); // defaults to null
        if ( $originParam === null ) {
            // No origin parameter, nothing to do
            return true;
Severity: Minor
Found in includes/api/ApiMain.php - About 3 hrs 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 execute has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute( $par ) {
        $user = $this->getUser();
        $request = $this->getRequest();
        $session = $request->getSession();
        $out = $this->getOutput();
Severity: Minor
Found in includes/specials/SpecialUserRights.php - About 3 hrs 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 fetchUser has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public function fetchUser( $username, $writing = true ) {
        $parts = explode( $this->getConfig()->get( MainConfigNames::UserrightsInterwikiDelimiter ),
            $username );
        if ( count( $parts ) < 2 ) {
            $name = trim( $username );
Severity: Minor
Found in includes/specials/SpecialUserRights.php - About 3 hrs 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 findFile has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public function findFile( $title, $options = [] ) {
        if ( !empty( $options['private'] ) && !( $options['private'] instanceof Authority ) ) {
            throw new InvalidArgumentException(
                __METHOD__ . ' called with the `private` option set to something ' .
                'other than an Authority object'
Severity: Minor
Found in includes/filerepo/FileRepo.php - About 3 hrs 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 initInternal has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    private function initInternal(
        PageIdentity $page,
        $body,
        array $parameters,
        ?RevisionRecord $originalRevision = null,
Severity: Minor
Found in includes/Rest/Handler/Helper/HtmlInputTransformHelper.php - About 3 hrs 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 doCategoryQuery has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doCategoryQuery() {
        $dbr = MediaWikiServices::getInstance()->getConnectionProvider()->getReplicaDatabase();

        $this->nextPage = [
            'page' => null,
Severity: Minor
Found in includes/Category/CategoryViewer.php - About 3 hrs 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 specialSearch has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    protected function specialSearch( $search, $limit, $offset ) {
        $searchParts = explode( '/', $search, 2 );
        $searchKey = $searchParts[0];
        $subpageSearch = $searchParts[1] ?? null;

Severity: Minor
Found in includes/search/PrefixSearch.php - About 3 hrs 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 filter has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public static function filter( $source ) {
        $tokens = token_get_all( $source );
        $buffer = null;
        $output = '';
        foreach ( $tokens as $token ) {
Severity: Minor
Found in maintenance/includes/MWDoxygenFilter.php - About 3 hrs 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 execute has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        global $wgLang, $wgAllowSchemaUpdates;

        if ( !$wgAllowSchemaUpdates
            && !( $this->hasOption( 'force' )
Severity: Minor
Found in maintenance/update.php - About 3 hrs 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 execute has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        if ( $this->hasOption( 'procs' ) ) {
            $procs = intval( $this->getOption( 'procs' ) );
            if ( $procs < 1 || $procs > 1000 ) {
                $this->fatalError( "Invalid argument to --procs" );
Severity: Minor
Found in maintenance/runJobs.php - About 3 hrs 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 execute has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $dbName = $this->getOption( 'wikidb', false );
        $lbf = $this->getServiceContainer()->getDBLoadBalancerFactory();

        // Pick LB
Severity: Minor
Found in maintenance/mysql.php - About 3 hrs 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 execute has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        global $IP, $wgLocalDatabases;

        $username = wfMessage( 'spambot_username' )->text();
        $user = User::newSystemUser( $username );
Severity: Minor
Found in maintenance/cleanupSpam.php - About 3 hrs 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 showPreview has 89 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function showPreview( file ) {
            let $canvas,
                ctx,
                meta,
                previewSize = 180,
Severity: Major
Found in resources/src/mediawiki.special.upload/upload.js - About 3 hrs to fix

    Function watchstar has 89 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function watchstar( $links, title, callback ) {
            // Set up the ARIA connection between the watch link and the notification.
            // This is set outside the click handler so that it's already present when the user clicks.
            const notificationId = 'mw-watchlink-notification';
            const mwTitle = mw.Title.newFromText( title );
    Severity: Major
    Found in resources/src/mediawiki.page.watch.ajax/watch-ajax.js - About 3 hrs to fix

      Function wrapMethod has 89 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              sinon.wrapMethod = function wrapMethod(object, property, method) {
                  if (!object) {
                      throw new TypeError("Should wrap property of object");
                  }
      
      
      Severity: Major
      Found in resources/lib/sinonjs/sinon.js - About 3 hrs to fix

        File Session.php has 315 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * MediaWiki session
         *
         * This program is free software; you can redistribute it and/or modify
        Severity: Minor
        Found in includes/session/Session.php - About 3 hrs to fix

          Method undeleteUnsafe has 89 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function undeleteUnsafe( string $comment ): StatusValue {
                  $hookStatus = $this->runPreUndeleteHook( $comment );
                  if ( !$hookStatus->isGood() ) {
                      return $hookStatus;
                  }
          Severity: Major
          Found in includes/page/UndeletePage.php - About 3 hrs to fix

            Method beginAuthentication has 89 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function beginAuthentication( array $reqs, $returnToUrl ) {
                    $session = $this->request->getSession();
                    if ( !$session->canSetUser() ) {
                        // Caller should have called canAuthenticateNow()
                        $session->remove( self::AUTHN_STATE );
            Severity: Major
            Found in includes/auth/AuthManager.php - About 3 hrs to fix
              Severity
              Category
              Status
              Source
              Language