wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function getWatchedItemsWithRCInfoQueryFilterConds has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    private function getWatchedItemsWithRCInfoQueryFilterConds(
        IReadableDatabase $dbr,
        User $user,
        array $options
    ) {
Severity: Minor
Found in includes/watchlist/WatchedItemQueryService.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 showPatrolFooter has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function showPatrolFooter() {
        $context = $this->getContext();
        $mainConfig = $context->getConfig();
        $useNPPatrol = $mainConfig->get( MainConfigNames::UseNPPatrol );
        $useRCPatrol = $mainConfig->get( MainConfigNames::UseRCPatrol );
Severity: Minor
Found in includes/page/Article.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 extractConfig2 has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    protected function extractConfig2( array $info, $dir ) {
        $prefix = $info['config_prefix'] ?? 'wg';
        if ( isset( $info['config'] ) ) {
            foreach ( $info['config'] as $key => $data ) {
                if ( !array_key_exists( 'value', $data ) ) {
Severity: Minor
Found in includes/registration/ExtensionProcessor.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 outputPageStreamBatch has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    protected function outputPageStreamBatch( $results, $lastRow ) {
        $rowCarry = null;
        while ( true ) {
            $slotRows = $this->getSlotRowBatch( $results, $rowCarry );

Severity: Minor
Found in includes/export/WikiExporter.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 renderNewRevision has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function renderNewRevision() {
        if ( $this->isContentOverridden ) {
            // The code below only works with a RevisionRecord object. We could construct a
            // fake RevisionRecord (here or in setContent), but since this does not seem
            // needed at the moment, we'll just fail for now.
Severity: Minor
Found in includes/diff/DifferenceEngine.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 getHelpInfo has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function getHelpInfo( $name, $settings, array $options ) {
        $settings = $this->normalizeSettings( $settings );
        $typeDef = $this->getTypeDef( $settings[self::PARAM_TYPE] );

        // Define ordering. Some are overwritten below, some expected from the TypeDef
Severity: Minor
Found in includes/libs/ParamValidator/ParamValidator.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 doGetFileStatMulti has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doGetFileStatMulti( array $params ) {
        $stats = [];

        $reqs = []; // (path => op)
        // (a) Check the containers of the paths...
Severity: Minor
Found in includes/libs/filebackend/SwiftFileBackend.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 _set has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    function _set( $cmd, $key, $val, $exp, $casToken = null ) {
        $this->_last_cmd_status = self::ERR_NONE;

        if ( !$this->_active ) {
            $this->_last_cmd_status = self::ERR_UNEXPECTED;
Severity: Minor
Found in includes/libs/objectcache/utils/MemcachedClient.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 setMainValue has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    private function setMainValue(
        $key,
        $value,
        $ttl,
        ?int $version,
Severity: Minor
Found in includes/libs/objectcache/WANObjectCache.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 get_multi has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_multi( $keys ) {
        $this->_last_cmd_status = self::ERR_NONE;

        if ( !$this->_active ) {
            $this->_last_cmd_status = self::ERR_UNEXPECTED;
Severity: Minor
Found in includes/libs/objectcache/utils/MemcachedClient.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 init has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    protected function init( $position, $asOfTime ) {
        $m = [];
        if ( preg_match( '!^(.+)\.(\d+)/(\d+)$!', $position, $m ) ) {
            $this->binLog = $m[1]; // ideally something like host name
            $this->logPos = [ self::CORD_INDEX => (int)$m[2], self::CORD_EVENT => $m[3] ];
Severity: Minor
Found in includes/libs/rdbms/database/position/MySQLPrimaryPos.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 getInputOOUI has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function getInputOOUI( $value ) {
        $this->mParent->getOutput()->addModules( 'oojs-ui-widgets' );

        // Reject nested arrays (T274955)
        $value = array_filter( $value, 'is_scalar' );
Severity: Minor
Found in includes/htmlform/fields/HTMLMultiSelectField.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 updateTags has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function updateTags( $tagsToAdd, $tagsToRemove, &$rc_id = null,
        &$rev_id = null, &$log_id = null, $params = null, RecentChange $rc = null,
        UserIdentity $user = null
    ) {
        $tagsToAdd = array_filter(
Severity: Minor
Found in includes/changetags/ChangeTagsStore.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 hebrewNumeral has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public static function hebrewNumeral( $num ) {
        static $table = [
            [ '', 'א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז', 'ח', 'ט', 'י' ],
            [ '', 'י', 'כ', 'ל', 'מ', 'נ', 'ס', 'ע', 'פ', 'צ', 'ק' ],
            [ '',
Severity: Minor
Found in includes/language/Language.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 transformImageMagick has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    protected function transformImageMagick( $image, $params ) {
        # use ImageMagick
        $mainConfig = MediaWikiServices::getInstance()->getMainConfig();
        $sharpenReductionThreshold = $mainConfig->get( MainConfigNames::SharpenReductionThreshold );
        $sharpenParameter = $mainConfig->get( MainConfigNames::SharpenParameter );
Severity: Minor
Found in includes/media/BitmapHandler.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 doAdd has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doAdd( $path, $params, $options, $key = null ) {
        // Make sure all paths start with a /
        if ( $path[0] !== '/' ) {
            $path = '/' . $path;
        }
Severity: Minor
Found in includes/Request/PathRouter.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 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute( $subpage ) {
        $this->rcSubpage = $subpage;

        if ( $this->considerActionsForDefaultSavedQuery( $subpage ) ) {
            // Don't bother rendering the page if we'll be performing a redirect (T330100).
Severity: Minor
Found in includes/specialpage/ChangesListSpecialPage.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 getPathInfo has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getPathInfo( $want = 'all' ) {
        // PATH_INFO is mangled due to https://bugs.php.net/bug.php?id=31892
        // And also by Apache 2.x, double slashes are converted to single slashes.
        // So we will use REQUEST_URI if possible.
        $url = $this->getServerInfo( 'REQUEST_URI' );
Severity: Minor
Found in includes/Request/WebRequest.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 getLocalNameFor has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function getLocalNameFor( $name, $subpage = false ) {
        $aliases = $this->contLang->getSpecialPageAliases();
        $aliasList = $this->getAliasList();

        // Find the first alias that maps back to $name
Severity: Minor
Found in includes/specialpage/SpecialPageFactory.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 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $pUser = $this->getUser();

        // Deny if the user is blocked and doesn't have the full 'userrights' permission.
        // This matches what Special:UserRights does for the web UI.
Severity: Minor
Found in includes/api/ApiUserrights.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

Severity
Category
Status
Source
Language