wikimedia/mediawiki-core

View on GitHub

Showing 9,711 of 11,779 total issues

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

    public function execute() {
        $this->initServices();

        if ( !$this->tempUserConfig->isEnabled() ) {
            $this->output( 'Temporary accounts are disabled' . PHP_EOL );
Severity: Minor
Found in maintenance/expireTemporaryAccounts.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 purgeRedundantText has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function purgeRedundantText( $delete = true ) {
        # Data should come off the master, wrapped in a transaction
        $dbw = $this->getPrimaryDB();
        $this->beginTransaction( $dbw, __METHOD__ );

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

    protected function rotateDb() {
        // Cleaning up old connections
        if ( isset( $this->lb ) ) {
            $this->lb->closeAll( __METHOD__ );
            unset( $this->lb );
Severity: Minor
Found in maintenance/includes/TextPassDumper.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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        if (
            ( $this->hasOption( 'from' ) && !$this->hasOption( 'to' ) ) ||
            ( !$this->hasOption( 'from' ) && $this->hasOption( 'to' ) )
        ) {
Severity: Minor
Found in maintenance/rebuildrecentchanges.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 formatHelpItems has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function formatHelpItems( array $items, $heading, $descWidth, $tab ) {
        if ( $items === [] ) {
            return '';
        }

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

    private static function isAbsolutePath( $path ) {
        if ( str_starts_with( $path, '/' ) ) {
            return true;
        }

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

    public function execute() {
        $username = $this->getOption( 'username', false );
        if ( $username === false ) {
            $user = User::newSystemUser( 'ScriptImporter', [ 'steal' => true ] );
        } else {
Severity: Minor
Found in maintenance/importSiteScripts.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 moveIllegalPage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function moveIllegalPage( $row ) {
        $legal = 'A-Za-z0-9_/\\\\-';
        $legalized = preg_replace_callback( "!([^$legal])!",
            [ $this, 'hexChar' ],
            $row->page_title );
Severity: Minor
Found in maintenance/cleanupTitles.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 setupLogging has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function setupLogging() {
        if ( $this->hasOption( 'd' ) ) {
            wfDeprecated( 'shell.php -d', '1.40' );
            $this->setupLegacy();
            return;
Severity: Minor
Found in maintenance/shell.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 processRow has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function processRow( $row ) {
        $display = Title::makeName( $row->page_namespace, $row->page_title );
        $verified = $this->getServiceContainer()->getContentLanguage()->normalize( $display );
        $title = Title::newFromText( $verified );

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

    protected function doDBUpdates() {
        $this->setBatchSize( $this->getOption( 'batch-size', $this->getBatchSize() ) );

        $dbw = $this->getDB( DB_PRIMARY );
        if ( $dbw->fieldExists(
Severity: Minor
Found in maintenance/populateChangeTagDef.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 clearLoginThrottle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function clearLoginThrottle( $rawUsername, $ip ) {
        $this->output( 'Clearing login throttle...' );

        $passwordAttemptThrottle = $this->getConfig()->get( MainConfigNames::PasswordAttemptThrottle );
        if ( !$passwordAttemptThrottle ) {
Severity: Minor
Found in maintenance/resetAuthenticationThrottle.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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        if ( $this->getServiceContainer()->getReadOnlyMode()->isReadOnly() ) {
            $this->fatalError( "Wiki is in read-only mode; you'll need to disable it for import to work." );
        }

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

    protected function getListingDiffRel( FileBackend $src, FileBackend $dst, $backendRel ) {
        $srcPathsRel = $src->getFileList( [
            'dir' => $src->getRootStoragePath() . "/$backendRel" ] );
        if ( $srcPathsRel === null ) {
            $this->fatalError( "Could not list files in source container." );
Severity: Minor
Found in maintenance/copyFileBackend.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 mccGetHelp has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function mccGetHelp( $command ) {
        $output = '';
        $commandList = [
            'get' => 'grabs something',
            'getsock' => 'lists sockets',
Severity: Minor
Found in maintenance/mcc.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 shouldDelete has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function shouldDelete( IReadableDatabase $db, Title $oldTitle, Title $newTitle ) {
        $oldRow = $db->newSelectQueryBuilder()
            ->select( [ 'ns' => 'rd_namespace', 'title' => 'rd_title' ] )
            ->from( 'page' )
            ->join( 'redirect', null, 'rd_from = page_id' )
Severity: Minor
Found in maintenance/uppercaseTitlesForUnicodeTransition.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 handleBatch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function handleBatch( $lowId ) {
        $batchSize = $this->getBatchSize();
        // range is inclusive, let's subtract one.
        $highId = $lowId + $batchSize - 1;
        $dbw = $this->getPrimaryDB();
Severity: Minor
Found in maintenance/migrateExternallinks.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 setConditions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function setConditions( IReadableDatabase $dbw, SelectQueryBuilder $queryBuilder, $fieldPrefix ) {
        $end = $this->getOption( 'end', false );
        $mime = $this->getOption( 'mime', false );
        $mediatype = $this->getOption( 'mediatype', false );
        $like = $this->getOption( 'metadata-contains', false );
Severity: Minor
Found in maintenance/refreshImageMetadata.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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $services = $this->getServiceContainer();

        $this->output( "Checking existence of old default messages..." );
        $dbr = $this->getReplicaDB();
Severity: Minor
Found in maintenance/deleteDefaultMessages.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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        // Shouldn't be needed for Postgres
        $dbw = $this->getPrimaryDB();
        if ( $dbw->getType() == 'postgres' ) {
            $this->fatalError( "This script is not needed when using Postgres.\n" );
Severity: Minor
Found in maintenance/rebuildtextindex.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