wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

    this.$handle.on( {
        keydown: this.onHandleMouseKeyDown.bind( this ),
        keyup: this.onHandleMouseKeyUp.bind( this ),
        mousedown: this.onHandleMouseKeyDown.bind( this ),
        mouseup: this.onHandleMouseKeyUp.bind( this )
Severity: Major
Found in resources/lib/ooui/oojs-ui-toolbars.js and 1 other location - About 2 hrs to fix
resources/lib/ooui/oojs-ui-core.js on lines 8970..8975

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

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

    this.$handle.on( {
        click: this.onClick.bind( this ),
        keydown: this.onKeyDown.bind( this ),
        focus: this.onFocus.bind( this ),
        blur: this.onBlur.bind( this )
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-toolbars.js on lines 2103..2108

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

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.SearchInputWidget.prototype.onIndicatorClick = function ( e ) {
    if ( e.which === OO.ui.MouseButtons.LEFT ) {
        // Clear the text field
        this.setValue( '' );
        this.focus();
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 12100..12107

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

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 6 locations. Consider refactoring.
Open

        if ( $params['user'] !== null || $params['excludeuser'] !== null ) {
            // Paranoia: avoid brute force searches (T19342)
            if ( !$this->getAuthority()->isAllowed( 'deletedhistory' ) ) {
                $bitmask = RevisionRecord::DELETED_USER;
            } elseif ( !$this->getAuthority()->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
Severity: Major
Found in includes/api/ApiQueryAllDeletedRevisions.php and 5 other locations - About 2 hrs to fix
includes/api/ApiQueryAllRevisions.php on lines 182..194
includes/api/ApiQueryDeletedRevisions.php on lines 192..204
includes/api/ApiQueryDeletedrevs.php on lines 240..254
includes/api/ApiQueryRecentChanges.php on lines 383..394
includes/api/ApiQueryRevisions.php on lines 354..366

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

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 6 locations. Consider refactoring.
Open

        if ( $params['user'] !== null || $params['excludeuser'] !== null ) {
            if ( !$this->getAuthority()->isAllowed( 'deletedhistory' ) ) {
                $bitmask = RevisionRecord::DELETED_USER;
            } elseif ( !$this->getAuthority()->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
                $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
Severity: Major
Found in includes/api/ApiQueryRecentChanges.php and 5 other locations - About 2 hrs to fix
includes/api/ApiQueryAllDeletedRevisions.php on lines 316..328
includes/api/ApiQueryAllRevisions.php on lines 182..194
includes/api/ApiQueryDeletedRevisions.php on lines 192..204
includes/api/ApiQueryDeletedrevs.php on lines 240..254
includes/api/ApiQueryRevisions.php on lines 354..366

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

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 6 locations. Consider refactoring.
Open

        if ( $params['user'] !== null || $params['excludeuser'] !== null ) {
            // Paranoia: avoid brute force searches (T19342)
            if ( !$this->getAuthority()->isAllowed( 'deletedhistory' ) ) {
                $bitmask = RevisionRecord::DELETED_USER;
            } elseif ( !$this->getAuthority()->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
Severity: Major
Found in includes/api/ApiQueryAllRevisions.php and 5 other locations - About 2 hrs to fix
includes/api/ApiQueryAllDeletedRevisions.php on lines 316..328
includes/api/ApiQueryDeletedRevisions.php on lines 192..204
includes/api/ApiQueryDeletedrevs.php on lines 240..254
includes/api/ApiQueryRecentChanges.php on lines 383..394
includes/api/ApiQueryRevisions.php on lines 354..366

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

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 6 locations. Consider refactoring.
Open

        if ( $params['user'] !== null || $params['excludeuser'] !== null ) {
            // Paranoia: avoid brute force searches (T19342)
            // (shouldn't be able to get here without 'deletedhistory', but
            // check it again just in case)
            if ( !$this->getAuthority()->isAllowed( 'deletedhistory' ) ) {
Severity: Major
Found in includes/api/ApiQueryDeletedrevs.php and 5 other locations - About 2 hrs to fix
includes/api/ApiQueryAllDeletedRevisions.php on lines 316..328
includes/api/ApiQueryAllRevisions.php on lines 182..194
includes/api/ApiQueryDeletedRevisions.php on lines 192..204
includes/api/ApiQueryRecentChanges.php on lines 383..394
includes/api/ApiQueryRevisions.php on lines 354..366

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

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 6 locations. Consider refactoring.
Open

        if ( $params['user'] !== null || $params['excludeuser'] !== null ) {
            // Paranoia: avoid brute force searches (T19342)
            if ( !$this->getAuthority()->isAllowed( 'deletedhistory' ) ) {
                $bitmask = RevisionRecord::DELETED_USER;
            } elseif ( !$this->getAuthority()->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
Severity: Major
Found in includes/api/ApiQueryDeletedRevisions.php and 5 other locations - About 2 hrs to fix
includes/api/ApiQueryAllDeletedRevisions.php on lines 316..328
includes/api/ApiQueryAllRevisions.php on lines 182..194
includes/api/ApiQueryDeletedrevs.php on lines 240..254
includes/api/ApiQueryRecentChanges.php on lines 383..394
includes/api/ApiQueryRevisions.php on lines 354..366

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

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 6 locations. Consider refactoring.
Open

            if ( $params['user'] !== null || $params['excludeuser'] !== null ) {
                // Paranoia: avoid brute force searches (T19342)
                if ( !$this->getAuthority()->isAllowed( 'deletedhistory' ) ) {
                    $bitmask = RevisionRecord::DELETED_USER;
                } elseif ( !$this->getAuthority()->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
Severity: Major
Found in includes/api/ApiQueryRevisions.php and 5 other locations - About 2 hrs to fix
includes/api/ApiQueryAllDeletedRevisions.php on lines 316..328
includes/api/ApiQueryAllRevisions.php on lines 182..194
includes/api/ApiQueryDeletedRevisions.php on lines 192..204
includes/api/ApiQueryDeletedrevs.php on lines 240..254
includes/api/ApiQueryRecentChanges.php on lines 383..394

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

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 ( $params['end'] !== null ) {
                    $op = ( $params['dir'] === 'newer' ? '<=' : '>=' ); // Yes, opposite of the above
                    // @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset False positive
                    $ts = $db->timestampOrNull( $params['end'] );
                    if ( $params['endid'] !== null ) {
Severity: Major
Found in includes/api/ApiQueryRevisions.php and 1 other location - About 2 hrs to fix
includes/api/ApiQueryRevisions.php on lines 297..309

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

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 ( $params['start'] !== null ) {
                    $op = ( $params['dir'] === 'newer' ? '>=' : '<=' );
                    // @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset False positive
                    $ts = $db->timestampOrNull( $params['start'] );
                    if ( $params['startid'] !== null ) {
Severity: Major
Found in includes/api/ApiQueryRevisions.php and 1 other location - About 2 hrs to fix
includes/api/ApiQueryRevisions.php on lines 311..323

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

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

File UserMailer.php has 272 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
Severity: Minor
Found in includes/mail/UserMailer.php - About 2 hrs to fix

    File MessagesEo.php has 272 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /** Esperanto (Esperanto)
     *
     * @file
     * @ingroup Languages
    Severity: Minor
    Found in languages/messages/MessagesEo.php - About 2 hrs to fix

      Function _parseIfd has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          this.JpegMeta.JpegFile.prototype._parseIfd = function _parseIfd(endian, _binary_data, base, ifd_offset, tags, name, description) {
              var num_fields = JpegMeta.parseNum(endian, _binary_data, base + ifd_offset, 2);
              /* Per tag variables */
              var i, j;
              var tag_base;
      Severity: Major
      Found in resources/src/mediawiki.libs.jpegmeta/jpegmeta.js - About 2 hrs to fix

        Function endOf has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function endOf(units) {
                var time, startOfDate;
                units = normalizeUnits(units);
                if (units === undefined || units === 'millisecond' || !this.isValid()) {
                    return this;
        Severity: Major
        Found in resources/lib/moment/moment.js - About 2 hrs to fix

          Function OoUiFieldLayout has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          OO.ui.FieldLayout = function OoUiFieldLayout( fieldWidget, config ) {
              // Allow passing positional parameters inside the config object
              if ( OO.isPlainObject( fieldWidget ) && config === undefined ) {
                  config = fieldWidget;
                  fieldWidget = config.fieldWidget;
          Severity: Major
          Found in resources/lib/ooui/oojs-ui-core.js - About 2 hrs to fix

            Method merge has 63 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function merge( Authority $performer, $reason = '' ) {
                    $status = new Status();
            
                    // Check validity and permissions required for merge
                    $validCheck = $this->isValidMerge(); // Check this first to check for null pages
            Severity: Major
            Found in includes/page/MergeHistory.php - About 2 hrs to fix

              Method makeModuleResponse has 63 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function makeModuleResponse( Context $context,
                      array $modules, array $missing = []
                  ) {
                      if ( $modules === [] && $missing === [] ) {
                          return <<<MESSAGE
              Severity: Major
              Found in includes/ResourceLoader/ResourceLoader.php - About 2 hrs to fix

                Method extractInfo has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function extractInfo( $path, array $info, $version ) {
                        $dir = dirname( $path );
                        $this->extractHooks( $info, $path );
                        $this->extractExtensionMessagesFiles( $dir, $info );
                        $this->extractRestModuleFiles( $dir, $info );
                Severity: Major
                Found in includes/registration/ExtensionProcessor.php - About 2 hrs to fix

                  Method convertGrammar has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function convertGrammar( $word, $case ) {
                          $grammarForms =
                              MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::GrammarForms );
                          if ( isset( $grammarForms['la'][$case][$word] ) ) {
                              return $grammarForms['la'][$case][$word];
                  Severity: Major
                  Found in includes/languages/LanguageLa.php - About 2 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language