wikimedia/mediawiki-core

View on GitHub

Showing 11,773 of 11,773 total issues

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

    public function onRunUpdateStart( DeferrableUpdate $update ): void {
        // Increment a counter metric
        $type = get_class( $update )
            . ( $update instanceof DeferrableCallback ? '_' . $update->getOrigin() : '' );
        $httpMethod = MW_ENTRY_POINT === 'cli' ? 'cli' : strtolower( $_SERVER['REQUEST_METHOD'] ?? 'GET' );
Severity: Minor
Found in includes/deferred/DeferredUpdatesScopeMediaWikiStack.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 checkPasswordCannotMatchDefaults has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function checkPasswordCannotMatchDefaults( $policyVal, UserIdentity $user, $password ) {
        static $blockedLogins = [
            // r75589
            'Useruser' => 'Passpass',
            'Useruser1' => 'Passpass1',
Severity: Minor
Found in includes/password/PasswordPolicyChecks.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 __get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function __get( $name ) {
        if ( isset( self::$deprecatedPublicProperties[$name] ) ) {
            [ $version, $class, $component, $getter ] = self::$deprecatedPublicProperties[$name];
            $qualifiedName = $class . '::$' . $name;
            wfDeprecated( $qualifiedName, $version, $component, 2 );
Severity: Minor
Found in includes/debug/DeprecationHelper.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 siteFromDB has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function siteFromDB( $wiki ) {
        // Allow override
        $def = $this->getWikiParams( $wiki );
        if ( $def['suffix'] !== null && $def['lang'] !== null ) {
            return [ $def['suffix'], $def['lang'] ];
Severity: Minor
Found in includes/config/SiteConfiguration.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 tidy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function tidy( $text, ?callable $textProcessor = null ) {
        $traceCallback = static function ( $msg ) {
            wfDebug( "RemexHtml: $msg" );
        };
        $formatter = new RemexCompatFormatter( [ 'textProcessor' => $textProcessor ] );
Severity: Minor
Found in includes/tidy/RemexDriver.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 makeRedirectContent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function makeRedirectContent( Title $destination, $text = '' ) {
        $optionalColon = '';

        if ( $destination->getNamespace() === NS_CATEGORY ) {
            $optionalColon = ':';
Severity: Minor
Found in includes/content/WikitextContentHandler.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 crypt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function crypt( string $password ): void {
        $lastHash = $password;
        foreach ( $this->config['types'] as $i => $type ) {
            // Construct pseudo-hash based on params and arguments
            /** @var ParameterizedPassword $passObj */
Severity: Minor
Found in includes/password/LayeredParameterizedPassword.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 getDataForSearchIndex has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getDataForSearchIndex(
        WikiPage $page,
        ParserOutput $parserOutput,
        SearchEngine $engine,
        ?RevisionRecord $revision = null
Severity: Minor
Found in includes/content/FileContentHandler.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 fillParserOutput has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function fillParserOutput(
        Content $content,
        ContentParseParams $cpoParams,
        ParserOutput &$output
    ) {
Severity: Minor
Found in includes/content/TextContentHandler.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 parseHash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function parseHash( ?string $hash ): void {
        parent::parseHash( $hash );

        if ( $hash === null ) {
            $this->params = $this->getDefaultParams();
Severity: Minor
Found in includes/password/ParameterizedPassword.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 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 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 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 batchFetchBlobs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function batchFetchBlobs( $cluster, array $ids ) {
        $dbr = $this->getReplica( $cluster );
        $res = $dbr->newSelectQueryBuilder()
            ->select( [ 'blob_id', 'blob_text' ] )
            ->from( $this->getTable( $dbr, $cluster ) )
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 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() {
        $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

Severity
Category
Status
Source
Language