wikimedia/mediawiki-core

View on GitHub

Showing 11,461 of 11,461 total issues

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

    private function maybePaginate( Closure $fn ) {
        if ( $this instanceof PaginatingSearchEngine ) {
            return $fn();
        }
        $this->limit++;
Severity: Minor
Found in includes/search/SearchEngine.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 replaceSection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function replaceSection( $sectionId, Content $with, $sectionTitle = '' ) {
        // @phan-suppress-previous-line PhanParamSignatureMismatch False positive
        $myModelId = $this->getModel();
        $sectionModelId = $with->getModel();

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

    public function getThumbnails( array $pageIdentities, ?int $size = 60 ): array {
        // add filenames for NS_FILE pages by default
        $fileNamesByPageId = $this->getFileNamesByPageId( $pageIdentities );
        $results = [];
        foreach ( $fileNamesByPageId as $pageId => $fileName ) {
Severity: Minor
Found in includes/search/SearchResultThumbnailProvider.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 render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function render( SearchResult $result, $position ) {
        $title = $result->getTitle();
        $titleSnippet = $result->getTitleSnippet();
        $snippet = $result->getTextSnippet();

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

    private function fetchBlob( $cluster, $id, $itemID ) {
        /**
         * One-step cache variable to hold base blobs; operations that
         * pull multiple revisions may often pull multiple times from
         * the same blob. By keeping the last-used one open, we avoid
Severity: Minor
Found in includes/externalstore/ExternalStoreDB.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function create( $type = null ) {
        $configuredClass = $this->config->getSearchType();
        $alternativesClasses = $this->config->getSearchTypes();

        if ( $type !== null && in_array( $type, $alternativesClasses ) ) {
Severity: Minor
Found in includes/search/SearchEngineFactory.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 output has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function output( $out, $channel = null ) {
        // This is sometimes called very early, before Setup.php is included.
        if ( defined( 'MW_SERVICE_BOOTSTRAP_COMPLETE' ) ) {
            // Flush stats periodically in long-running CLI scripts to avoid OOM (T181385)
            $stats = $this->getServiceContainer()->getStatsdDataFactory();
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 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 countDown has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function countDown( $seconds ) {
        if ( $this->isQuiet() ) {
            return;
        }
        for ( $i = $seconds; $i >= 0; $i-- ) {
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 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 shouldExecute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function shouldExecute() {
        if ( !function_exists( 'debug_backtrace' ) ) {
            // If someone has a better idea...
            return MW_ENTRY_POINT === 'cli';
        }
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 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 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 expandScriptFile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function expandScriptFile( string $scriptName, ?array $extension ): string {
        // Append ".php" if not present
        $scriptFile = $scriptName;
        if ( !str_ends_with( $scriptFile, '.php' ) ) {
            $scriptFile .= '.php';
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 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 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 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 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 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 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

Severity
Category
Status
Source
Language