wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function __construct has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( array $keys, ...$sources ) {
        $this->keys = $keys;
        foreach ( $keys as $key ) {
            foreach ( $sources as $source ) {
                if ( $source instanceof Config ) {
Severity: Minor
Found in includes/config/ServiceOptions.php - About 2 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 getPsr3MessageAndContext has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function getPsr3MessageAndContext( StatusValue $status ): array {
        $options = [ 'lang' => 'en' ];
        $errors = $status->getErrors();

        if ( count( $errors ) === 1 ) {
Severity: Minor
Found in includes/Status/StatusFormatter.php - About 2 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 recentChangesBlockLine has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    protected function recentChangesBlockLine( $rcObj ) {
        $data = [];

        $type = $rcObj->mAttribs['rc_type'];
        $logType = $rcObj->mAttribs['rc_log_type'];
Severity: Minor
Found in includes/recentchanges/EnhancedChangesList.php - About 2 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 startElement has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    protected function startElement( $parser, $name, $attribs ) {
        $this->checkpointJustWritten = false;

        $this->clearOpenElement( null );
        $this->lastName = $name;
Severity: Minor
Found in maintenance/includes/TextPassDumper.php - About 2 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 trackOrphanText has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    private function trackOrphanText() {
        # Wait until the blob_tracking table is available in the replica DB
        $dbw = $this->getPrimaryDB();
        $dbr = $this->getReplicaDB();
        $this->getServiceContainer()->getDBLoadBalancerFactory()->waitForReplication( [ 'timeout' => 100_000 ] );
Severity: Minor
Found in maintenance/storage/trackBlobs.php - About 2 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 trackRevisions has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    private function trackRevisions() {
        $dbw = $this->getPrimaryDB();
        $dbr = $this->getReplicaDB();

        $textClause = $this->getTextClause();
Severity: Minor
Found in maintenance/storage/trackBlobs.php - About 2 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 showUsageStats has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    private function showUsageStats() {
        $option = $this->getArg( 0 );

        $ret = [];
        $userOptionsLookup = $this->getServiceContainer()->getUserOptionsLookup();
Severity: Minor
Found in maintenance/userOptions.php - About 2 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 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $userName = $this->getOption( 'user', false );
        $summary = $this->getOption( 'summary', '' );
        $remove = $this->hasOption( 'remove' );
        $minor = $this->hasOption( 'minor' );
Severity: Minor
Found in maintenance/edit.php - About 2 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

File GitInfo.php has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
Severity: Minor
Found in includes/utils/GitInfo.php - About 2 hrs to fix

    File userOptions.php has 274 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Script to change users preferences on the fly.
     *
     * Made on an original idea by Fooey (freenode)
    Severity: Minor
    Found in maintenance/userOptions.php - About 2 hrs to fix

      Function _showDatepicker has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _showDatepicker: function(input) {
              input = input.target || input;
              if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
                  input = $('input', input.parentNode)[0];
              if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
      Severity: Major
      Found in resources/lib/jquery.ui/jquery.ui.datepicker.js - About 2 hrs to fix

        Method save has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function save() {
                # Permission check!
                if ( $this->disabled ) {
                    $this->show();
                    return false;
        Severity: Major
        Found in includes/page/ProtectionForm.php - About 2 hrs to fix

          Method logPotentialSessionLeakage has 64 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function logPotentialSessionLeakage( Session $session = null ) {
                  $proxyLookup = MediaWikiServices::getInstance()->getProxyLookup();
                  $session = $session ?: self::getGlobalSession();
                  $suspiciousIpExpiry = $this->config->get( MainConfigNames::SuspiciousIpExpiry );
          
          
          Severity: Major
          Found in includes/session/SessionManager.php - About 2 hrs to fix

            Method getData has 64 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function getData(): array {
                    if ( $this->data ) {
                        return $this->data;
                    }
            
            
            Severity: Major
            Found in includes/ResourceLoader/ClientHtml.php - About 2 hrs to fix

              Method doOperationsInternal has 64 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  final protected function doOperationsInternal( array $ops, array $opts ) {
                      $status = $this->newStatus();
              
                      $fname = __METHOD__;
                      $mbe = $this->backends[$this->masterIndex]; // convenience
              Severity: Major
              Found in includes/libs/filebackend/FileBackendMultiWrite.php - About 2 hrs to fix

                Method getInclusiveMetrics has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getInclusiveMetrics() {
                        if ( $this->inclusive === null ) {
                            $main = $this->hieraData['main()'];
                            $hasCpu = isset( $main['cpu'] );
                            $hasMu = isset( $main['mu'] );
                Severity: Major
                Found in includes/libs/XhprofData.php - About 2 hrs to fix

                  Method onSubmit has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function onSubmit( $data ) {
                          if ( !$this->getRequest()->getCheck( 'wpSave' ) ) {
                              // Diff or preview
                              return false;
                          }
                  Severity: Major
                  Found in includes/actions/McrUndoAction.php - About 2 hrs to fix

                    Method getTemplateData has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function getTemplateData(): array {
                            // Optimization: Generate once.
                            if ( $this->cachedData ) {
                                return $this->cachedData;
                            }
                    Severity: Major
                    Found in includes/skins/components/SkinComponentSearch.php - About 2 hrs to fix

                      Method parseTitle has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function parseTitle( $request ) {
                              $curid = $request->getInt( 'curid' );
                              $title = $request->getText( 'title' );
                      
                              $ret = null;
                      Severity: Major
                      Found in includes/actions/ActionEntryPoint.php - About 2 hrs to fix

                        Method extractParam has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function extractParam( $param, $format ) {
                                if ( is_array( $param ) ) {
                                    if ( isset( $param['raw'] ) ) {
                                        return [ 'after', $param['raw'] ];
                                    } elseif ( isset( $param['num'] ) ) {
                        Severity: Major
                        Found in includes/Message/Message.php - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language