wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function parse has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    private function parse( string $timeCorrection, int $systemOffset ) {
        $data = explode( '|', $timeCorrection, 3 );

        // First handle the case of an actual timezone being specified.
        if ( $data[0] === self::ZONEINFO ) {
Severity: Minor
Found in includes/user/UserTimeCorrection.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 getUserAutopromoteOnceGroups has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function getUserAutopromoteOnceGroups(
        UserIdentity $user,
        string $event
    ): array {
        $user->assertWiki( $this->wikiId );
Severity: Minor
Found in includes/user/UserGroupManager.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 makeIndexes has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public static function makeIndexes( $url, $reverseDomain = true ) {
        // NOTE: refreshExternallinksIndex.php assumes that only protocol-relative URLs return more
        // than one index, and that the indexes for protocol-relative URLs only vary in the "http://"
        // versus "https://" prefix. If you change that, you'll likely need to update
        // refreshExternallinksIndex.php accordingly.
Severity: Minor
Found in includes/ExternalLinks/LinkFilter.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 insert has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function insert( $data, array $params = [], array $tryStores = null ) {
        $tryStores ??= $this->storeFactory->getWriteBaseUrls();
        if ( !$tryStores ) {
            throw new ExternalStoreException( "List of external stores provided is empty." );
        }
Severity: Minor
Found in includes/externalstore/ExternalStoreAccess.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 reconstructAFE has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function reconstructAFE( $sourceStart ) {
        // These checks are redundant with the parent, but here for performance
        $entry = $this->afe->getTail();
        if ( !$entry || $entry instanceof Marker || $entry->stackIndex !== null ) {
            return;
Severity: Minor
Found in includes/tidy/RemexCompatBuilder.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 initialize has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    protected function initialize( $mode = self::LOAD_ONLY ) {
        if ( $this->mName === null && $this->mID === null ) {
            throw new RuntimeException( __METHOD__ . ' has both names and IDs null' );
        } elseif ( $this->mID === null ) {
            $where = [ 'cat_title' => $this->mName ];
Severity: Minor
Found in includes/Category/Category.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 getSearchIndexFields has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function getSearchIndexFields() {
        $models = MediaWikiServices::getInstance()->getContentHandlerFactory()->getContentModels();
        $fields = [];
        $seenHandlers = new SplObjectStorage();
        foreach ( $models as $model ) {
Severity: Minor
Found in includes/search/SearchEngine.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 loadThing has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    private function loadThing( &$dependencies, $name, $extensions, $skins ) {
        $extDir = $this->getConfig()->get( MainConfigNames::ExtensionDirectory );
        $styleDir = $this->getConfig()->get( MainConfigNames::StyleDirectory );
        $queue = [];
        $missing = false;
Severity: Minor
Found in maintenance/checkDependencies.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 addToDependencies has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    private function addToDependencies( &$dependencies, $extensions, $skins,
        $why = null, $status = null, $message = null
    ) {
        $mainRegistry = ExtensionRegistry::getInstance();
        $iter = [ 'extensions' => $extensions, 'skins' => $skins ];
Severity: Minor
Found in maintenance/checkDependencies.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 handleChar has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    protected function handleChar() {
        $attrs = $this->readAttributes() + $this->groupAttrs;
        if ( isset( $attrs['cp'] ) ) {
            $first = $last = hexdec( $attrs['cp'] );
        } else {
Severity: Minor
Found in maintenance/language/generateCollationData.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 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $services = $this->getServiceContainer();
        $userFactory = $services->getUserFactory();
        $userGroupManager = $services->getUserGroupManager();
        $this->output( "Remove unused accounts\n\n" );
Severity: Minor
Found in maintenance/removeUnusedAccounts.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 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $repo = $this->getServiceContainer()->getRepoGroup()->getLocalRepo();
        $start = str_replace( ' ', '_', $this->getOption( 'start', '' ) ); // page on img_name
        $end = str_replace( ' ', '_', $this->getOption( 'end', '' ) ); // page on img_name
        // filter by img_media_type
Severity: Minor
Found in maintenance/refreshFileHeaders.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 doSpecialPageCacheUpdates has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function doSpecialPageCacheUpdates( $dbw ) {
        foreach ( $this->getConfig()->get( MainConfigNames::SpecialPageCacheUpdates ) as $special => $call ) {
            # --list : just show the name of pages
            if ( $this->hasOption( 'list' ) ) {
                $this->output( "$special [callback]\n" );
Severity: Minor
Found in maintenance/updateSpecialPages.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
                (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
Severity: Major
Found in resources/lib/jquery.ui/jquery.ui.draggable.js and 1 other location - About 2 hrs to fix
resources/lib/jquery.ui/jquery.ui.draggable.js on lines 770..770

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 80.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

          for (var c = n - 1 >> 1; n > 0 && e.score < r[c].score; c = (n = c) - 1 >> 1) {
            r[n] = r[c];
          }
Severity: Major
Found in resources/lib/qunitjs/qunit.js and 1 other location - About 2 hrs to fix
resources/lib/qunitjs/qunit.js on lines 5102..5104

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 80.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

                if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
Severity: Major
Found in resources/lib/jquery.ui/jquery.ui.draggable.js and 1 other location - About 2 hrs to fix
resources/lib/jquery.ui/jquery.ui.draggable.js on lines 799..800

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 80.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

                                    $rowUnwatchLink
                                        .text( mw.msg( 'watchlist-unwatch' ) )
                                        .attr( 'title', mw.msg( 'tooltip-ca-unwatch' ) )
                                        .attr( 'href',
                                            mw.util.getUrl( rowPageTitle, { action: 'unwatch' } ) )
Severity: Major
Found in resources/src/mediawiki.special.watchlist/watchlist.js and 1 other location - About 2 hrs to fix
resources/src/mediawiki.special.watchlist/watchlist.js on lines 117..123

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 80.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

                                    $rowUnwatchLink
                                        .text( mw.msg( 'watchlist-unwatch-undo' ) )
                                        .attr( 'title', mw.msg( 'tooltip-ca-watch' ) )
                                        .attr( 'href',
                                            mw.util.getUrl( rowPageTitle, { action: 'watch' } ) )
Severity: Major
Found in resources/src/mediawiki.special.watchlist/watchlist.js and 1 other location - About 2 hrs to fix
resources/src/mediawiki.special.watchlist/watchlist.js on lines 139..145

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 80.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
        var weekday = config._locale.weekdaysParse(input, token, config._strict);
        // if we didn't get a weekday name, mark the date as invalid
        if (weekday != null) {
            week.d = weekday;
Severity: Major
Found in resources/lib/moment/moment.js and 1 other location - About 2 hrs to fix
resources/lib/moment/moment.js on lines 938..946

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 80.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

OO.ui.MenuSelectWidget.prototype.removeItems = function ( items ) {
    // Parent method
    OO.ui.MenuSelectWidget.super.prototype.removeItems.call( this, items );

    this.updateItemVisibility();
Severity: Major
Found in resources/lib/ooui/oojs-ui-core.js and 1 other location - About 2 hrs to fix
resources/lib/ooui/oojs-ui-core.js on lines 14041..14046

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 80.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Severity
Category
Status
Source
Language