wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function formatChangeLine has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function formatChangeLine( RecentChange $rc, array &$classes, $watched ) {
        $html = '';
        $unpatrolled = $this->showAsUnpatrolled( $rc );

        if ( $rc->mAttribs['rc_log_type'] ) {
Severity: Minor
Found in includes/recentchanges/OldChangesList.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 save has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function save( $send = self::SEND_FEED ) {
        $services = MediaWikiServices::getInstance();
        $mainConfig = $services->getMainConfig();
        $putIPinRC = $mainConfig->get( MainConfigNames::PutIPinRC );
        $dbw = $services->getConnectionProvider()->getPrimaryDatabase();
Severity: Minor
Found in includes/recentchanges/RecentChange.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 benchmarkSingleKeyOps has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function benchmarkSingleKeyOps( BagOStuff $mcc, array $valueByKey ) {
        $add = 0;
        $set = 0;
        $incr = 0;
        $get = 0;
Severity: Minor
Found in maintenance/mctest.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 showSortKeySizeHistogram has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function showSortKeySizeHistogram() {
        if ( !$this->sizeHistogram ) {
            return;
        }
        $maxLength = max( array_keys( $this->sizeHistogram ) );
Severity: Minor
Found in maintenance/updateCollation.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 execute has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $services = $this->getServiceContainer();
        $languageFactory = $services->getLanguageFactory();
        $languageConverterFactory = $services->getLanguageConverterFactory();
        $variantLangs = [];
Severity: Minor
Found in maintenance/language/listVariants.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 getRowsOld has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function getRowsOld( $fromId ) {
        $dbr = $this->getReplicaDB();
        $batchSize = $this->getBatchSize();
        $before = $this->getOption( 'before', false );

Severity: Minor
Found in maintenance/deleteAutoPatrolLogs.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 mungeTitle has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function mungeTitle( IReadableDatabase $db, Title $oldTitle, Title &$newTitle ) {
        $nt = $newTitle->getPrefixedText();

        $munge = false;
        if ( $this->isUserPage( $db, $newTitle->getNamespace(), $newTitle->getText() ) ) {
Severity: Minor
Found in maintenance/uppercaseTitlesForUnicodeTransition.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 execute has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $user = $this->getOption( 'user' );
        $services = $this->getServiceContainer();
        $userNameUtils = $services->getUserNameUtils();
        $user = $userNameUtils->isIP( $user ) ? $user : $userNameUtils->getCanonical( $user );
Severity: Minor
Found in maintenance/rollbackEdits.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 execute has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $dbw = $this->getPrimaryDB();
        $dbr = $this->getReplicaDB();
        $maxLtId = (int)$dbr->newSelectQueryBuilder()
            ->select( 'MAX(lt_id)' )
Severity: Minor
Found in maintenance/pruneUnusedLinkTargetRows.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 validateParamsAndArgs has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function validateParamsAndArgs() {
        $error_out = false;

        # Get the format and make sure it is set to a valid default value
        $format = strtolower( $this->getOption( 'format', 'PHP' ) );
Severity: Minor
Found in maintenance/getConfiguration.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 pokeFile has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function pokeFile( $orig, $new ) {
        $path = $this->filePath( $orig );
        if ( !file_exists( $path ) ) {
            $this->output( "missing file: $path\n" );
            $this->killRow( $orig );
Severity: Minor
Found in maintenance/cleanupImages.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 doDBUpdates has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doDBUpdates() {
        $batchSize = $this->getBatchSize();

        $dbw = $this->getDB( DB_PRIMARY );
        if ( !$dbw->fieldExists( 'revision', 'rev_actor', __METHOD__ ) ) {
Severity: Minor
Found in maintenance/migrateRevisionActorTemp.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 execute has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $count = 0;
        $oldGroup = $this->getArg( 0 );
        $newGroup = $this->getArg( 1 );
        $dbw = $this->getPrimaryDB();
Severity: Minor
Found in maintenance/migrateUserGroup.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 execute has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        if ( $this->hasOption( 'showgrants' ) ) {
            $this->showGrants();
            return;
        }
Severity: Minor
Found in maintenance/createBotPassword.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

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

    mw.htmlform.FieldLayout = function ( config ) {
        // Parent constructor
        mw.htmlform.FieldLayout.super.call( this, config );
        // Mixin constructors
        mw.htmlform.Element.call( this, config );
Severity: Major
Found in resources/src/mediawiki.htmlform.ooui/Element.js and 1 other location - About 1 hr to fix
resources/src/mediawiki.htmlform.ooui/Element.js on lines 65..70

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 73.

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.RadioInputWidget.prototype.simulateLabelClick = function () {
    if ( !this.isDisabled() ) {
        this.$input.trigger( 'click' );
    }
    this.focus();
Severity: Major
Found in resources/lib/ooui/oojs-ui-core.js and 1 other location - About 1 hr to fix
resources/lib/ooui/oojs-ui-core.js on lines 10528..10533

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 73.

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

        else if (/^(ne)$/.test(a)) {
            that.size.width = os.width + ox;
            that.size.height = os.height + oy;
            that.position.top = op.top - oy;
        }
Severity: Major
Found in resources/lib/jquery.ui/jquery.ui.resizable.js and 1 other location - About 1 hr to fix
resources/lib/jquery.ui/jquery.ui.resizable.js on lines 778..788

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 73.

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

        else if (/^(sw)$/.test(a)) {
            that.size.width = os.width + ox;
            that.size.height = os.height + oy;
            that.position.left = op.left - ox;
        }
Severity: Major
Found in resources/lib/jquery.ui/jquery.ui.resizable.js and 1 other location - About 1 hr to fix
resources/lib/jquery.ui/jquery.ui.resizable.js on lines 773..788

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 73.

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.CheckboxInputWidget.prototype.simulateLabelClick = function () {
    if ( !this.isDisabled() ) {
        this.$handle.trigger( 'click' );
    }
    this.focus();
Severity: Major
Found in resources/lib/ooui/oojs-ui-core.js and 1 other location - About 1 hr to fix
resources/lib/ooui/oojs-ui-core.js on lines 10977..10982

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 73.

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

    mw.htmlform.ActionFieldLayout = function ( config ) {
        // Parent constructor
        mw.htmlform.ActionFieldLayout.super.call( this, config );
        // Mixin constructors
        mw.htmlform.Element.call( this, config );
Severity: Major
Found in resources/src/mediawiki.htmlform.ooui/Element.js and 1 other location - About 1 hr to fix
resources/src/mediawiki.htmlform.ooui/Element.js on lines 45..50

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 73.

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