wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function resolveGroups has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function resolveGroups( $groups, $i ) {
        // If a specific replica server was specified, then $groups makes no sense
        if ( $i > 0 && $groups !== [] && $groups !== false ) {
            $list = implode( ', ', (array)$groups );
            throw new LogicException( "Query group(s) ($list) given with server index (#$i)" );
Severity: Minor
Found in includes/libs/rdbms/loadbalancer/LoadBalancer.php - About 1 hr 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 getClass has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getClass( $dbType, $driver = null ) {
        // For database types with built-in support, the below maps type to IDatabase
        // implementations. For types with multiple driver implementations (PHP extensions),
        // an array can be used, keyed by extension name. In case of an array, the
        // optional 'driver' parameter can be used to force a specific driver. Otherwise,
Severity: Minor
Found in includes/libs/rdbms/database/DatabaseFactory.php - About 1 hr 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 transactionWritingOut has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function transactionWritingOut(
        $server,
        $db,
        string $id,
        float $writeTime,
Severity: Minor
Found in includes/libs/rdbms/TransactionProfiler.php - About 1 hr 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 trackBlockWithCookie has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function trackBlockWithCookie( User $user, WebResponse $response ) {
        if ( !$this->options->get( MainConfigNames::CookieSetOnIpBlock ) &&
            !$this->options->get( MainConfigNames::CookieSetOnAutoblock ) ) {
            // Cookie blocks are disabled, return early to prevent executing unnecessary logic.
            return;
Severity: Minor
Found in includes/block/BlockManager.php - About 1 hr 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 getStartBody has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getStartBody() {
        $sortClass = $this->getSortHeaderClass();

        $s = '';
        $fields = $this->getFieldNames();
Severity: Minor
Found in includes/pager/TablePager.php - About 1 hr 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 getBody has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function getBody() {
        $this->getOutput()->addModuleStyles( $this->getModuleStyles() );
        if ( !$this->mQueryDone ) {
            $this->doQuery();
        }
Severity: Minor
Found in includes/pager/IndexPager.php - About 1 hr 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 tabAction has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
        $classes = [];
        if ( $selected ) {
            $classes[] = 'selected';
        }
Severity: Minor
Found in includes/skins/SkinTemplate.php - About 1 hr 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 placeBlock has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function placeBlock( bool $reblock = false ): Status {
        $priorBlock = $this->blockStore
            ->newFromTarget( $this->target, null, /*fromPrimary=*/true );
        $priorHideUser = $priorBlock instanceof DatabaseBlock && $priorBlock->getHideName();
        if (
Severity: Minor
Found in includes/block/BlockUser.php - About 1 hr 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 tryNormaliseRedirect has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function tryNormaliseRedirect( Title $title ): bool {
        $request = $this->getRequest();
        $output = $this->getOutput();

        if ( $request->getRawVal( 'action', 'view' ) != 'view'
Severity: Minor
Found in includes/actions/ActionEntryPoint.php - About 1 hr 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 performAction has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function performAction( Article $article, Title $requestTitle ) {
        $request = $this->getRequest();
        $output = $this->getOutput();
        $title = $this->getTitle();
        $user = $this->getUser();
Severity: Minor
Found in includes/actions/ActionEntryPoint.php - About 1 hr 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 fetchValuesFromRequest has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function fetchValuesFromRequest( WebRequest $r, $optionKeys = null ) {
        if ( !$optionKeys ) {
            $optionKeys = array_keys( $this->options );
        }

Severity: Minor
Found in includes/Html/FormOptions.php - About 1 hr 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 unpack has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function unpack( $string, $struct, $offset = 0 ) {
        $size = $this->getStructSize( $struct );
        if ( $offset + $size > strlen( $string ) ) {
            $this->error( 'zip-bad', 'unpack() would run past the end of the supplied string' );
        }
Severity: Minor
Found in includes/utils/ZipDirectoryReader.php - About 1 hr 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 getErrorsOrWarnings has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function getErrorsOrWarnings( $elements, $elementsType ) {
        if ( !in_array( $elementsType, [ 'error', 'warning' ], true ) ) {
            throw new DomainException( $elementsType . ' is not a valid type.' );
        }
        $elementstr = false;
Severity: Minor
Found in includes/htmlform/HTMLForm.php - About 1 hr 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 loadFromArray has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function loadFromArray( array $restrictions ) {
        static $neededKeys = [ 'IPAddresses' ];

        $keys = array_keys( $restrictions );
        $missingKeys = array_diff( $neededKeys, $keys );
Severity: Minor
Found in includes/utils/MWRestrictions.php - About 1 hr 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 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function get( $key, $useDB = true, $language = null, &$usedKey = '' ) {
        if ( is_int( $key ) ) {
            // Fix numerical strings that somehow become ints on their way here
            $key = (string)$key;
        } elseif ( !is_string( $key ) ) {
Severity: Minor
Found in includes/language/MessageCache.php - About 1 hr 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 getHumanTimestampInternal has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function getHumanTimestampInternal(
        MWTimestamp $ts, MWTimestamp $relativeTo, User $user
    ) {
        $diff = $ts->diff( $relativeTo );
        $diffDay = (bool)( (int)$ts->timestamp->format( 'w' ) -
Severity: Minor
Found in includes/language/Language.php - About 1 hr 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 makeSiteList has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function makeSiteList( DOMElement $root ) {
        $sites = [];

        // Old sites, to get the row IDs that correspond to the global site IDs.
        // TODO: Get rid of internal row IDs, they just get in the way. Get rid of ORMRow, too.
Severity: Minor
Found in includes/site/SiteImporter.php - About 1 hr 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 assertValidServerConfigs has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function assertValidServerConfigs( array $servers, string $ldDB, string $ldTP ): void {
        foreach ( $servers as $server ) {
            $type = $server['type'] ?? null;
            $srvDB = $server['dbname'] ?? null; // server DB
            $srvTP = $server['tablePrefix'] ?? ''; // server table prefix
Severity: Minor
Found in includes/db/MWLBFactory.php - About 1 hr 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 handleSVGAttribs has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function handleSVGAttribs() {
        $defaultWidth = self::DEFAULT_WIDTH;
        $defaultHeight = self::DEFAULT_HEIGHT;
        $aspect = 1.0;
        $width = null;
Severity: Minor
Found in includes/media/SVGReader.php - About 1 hr 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 formatNum has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function formatNum( $num, $round = false, $tagName = null ) {
        $m = [];
        if ( is_array( $num ) ) {
            $out = [];
            foreach ( $num as $number ) {
Severity: Minor
Found in includes/media/FormatMetadata.php - About 1 hr 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