wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Method dfnCheckInterval has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function dfnCheckInterval( $start = null, $end = null, $batchSize = 100 ) {
        $dbw = $this->getPrimaryDB();
        $dbr = $this->getDB( DB_REPLICA, [ 'vslow' ] );

        $linksTables = [
Severity: Minor
Found in maintenance/refreshLinks.php - About 1 hr to fix

    Method fetchMessageInfo has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function fetchMessageInfo( $langCode, array &$messageInfo ) {
            $services = $this->getServiceContainer();
            $contLang = $services->getContentLanguage();
            if ( $langCode ) {
                $this->output( "\n... fetching message info for language: $langCode" );
    Severity: Minor
    Found in maintenance/deleteEqualMessages.php - About 1 hr to fix

      Method doAllPages has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function doAllPages() {
              $dbr = MediaWikiServices::getInstance()->getConnectionProvider()->getReplicaDatabase();
              $i = 0;
              $startId = 0;
              if ( $this->noCount ) {
      Severity: Minor
      Found in maintenance/storage/recompressTracked.php - About 1 hr to fix

        Method updateTo2 has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function updateTo2( &$json ) {
                if ( isset( $json['config'] ) ) {
                    $config = $json['config'];
                    $json['config'] = [];
                    if ( isset( $config['_prefix'] ) ) {
        Severity: Minor
        Found in maintenance/updateExtensionJsonSchema.php - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                      if ( date.getTime() < -62167219200000 || date.getTime() > 253402300799999 ||
                          date.getUTCFullYear() !== +m[ 1 ] ||
                          date.getUTCMonth() + 1 !== +m[ 2 ] ||
                          date.getUTCDate() !== +m[ 3 ] ||
                          date.getUTCHours() !== +m[ 4 ] ||
          Severity: Critical
          Found in resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                    if (
                        title.indexOf( '.' ) !== -1 && (
                            title === '.' || title === '..' ||
                            title.indexOf( './' ) === 0 ||
                            title.indexOf( '../' ) === 0 ||
            Severity: Critical
            Found in resources/src/mediawiki.Title/Title.js - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                      if ( ( ( $target[0].id != $.datepicker._mainDivId &&
                              $target.parents('#' + $.datepicker._mainDivId).length == 0 &&
                              !$target.hasClass($.datepicker.markerClassName) &&
                              !$target.closest("." + $.datepicker._triggerClass).length &&
                              $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
              Severity: Critical
              Found in resources/lib/jquery.ui/jquery.ui.datepicker.js - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                        if(!(/^(document|window|parent)$/).test(o.containment)) {
                            var ce = $(o.containment)[0];
                            var co = $(o.containment).offset();
                            var over = ($(ce).css("overflow") != 'hidden');
                
                
                Severity: Critical
                Found in resources/lib/jquery.ui/jquery.ui.sortable.js - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                          if (this.floating && horizontalDirection) {
                              return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf));
                          } else {
                              return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && !isOverBottomHalf));
                          }
                  Severity: Critical
                  Found in resources/lib/jquery.ui/jquery.ui.sortable.js - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                                        if ( $userOptionsLookup->getOption( $watchingUser, 'enotifwatchlistpages' )
                                            && ( !$minorEdit || $userOptionsLookup->getOption( $watchingUser, 'enotifminoredits' ) )
                                            && $watchingUser->isEmailConfirmed()
                                            && $watchingUser->getId() != $userTalkId
                                            && !in_array( $watchingUser->getName(),
                    Severity: Critical
                    Found in includes/mail/EmailNotification.php - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                              if ( $delta & 1 ) {
                                  for ( $d = 0; $d <= $limit; ++$d ) {
                                      $start_diag = max( $value_to_add_forward + $start_forward, -$d );
                                      $end_diag = min( $end_forward, $d );
                                      $value_to_add_forward = 1 - $value_to_add_forward;
                      Severity: Critical
                      Found in includes/libs/Diff/DiffEngine.php - About 1 hr to fix

                        Consider simplifying this complex logical expression.
                        Open

                                if (
                                    !$this->mOldRevisionRecord || !$this->mNewRevisionRecord
                                    || !$this->mOldPage || !$this->mNewPage
                                    || !$this->mOldPage->equals( $this->mNewPage )
                                    || $this->mOldRevisionRecord->getId() === null
                        Severity: Critical
                        Found in includes/diff/DifferenceEngine.php - About 1 hr to fix

                          Consider simplifying this complex logical expression.
                          Open

                                  if (
                                      str_contains( $dbkey, '.' ) &&
                                      (
                                          $dbkey === '.' || $dbkey === '..' ||
                                          str_starts_with( $dbkey, './' ) ||
                          Severity: Critical
                          Found in includes/title/MediaWikiTitleCodec.php - About 1 hr to fix

                            Consider simplifying this complex logical expression.
                            Open

                                        if ( $customised !== $this->custom &&
                                            ( ( $asc && ( $key < $offset || !$offset ) ) || ( !$asc && $key > $offset ) ) &&
                                            ( ( $this->prefix && preg_match( $this->prefix, $key ) ) || $this->prefix === false )
                                        ) {
                                            $actual = $this->msg( $key )->inLanguage( $this->lang )->plain();
                            Severity: Critical
                            Found in includes/specials/pagers/AllMessagesTablePager.php - About 1 hr to fix

                              Consider simplifying this complex logical expression.
                              Open

                                      if ( isset( self::METADATA_ELEMENTS[$elementName] )
                                          && !self::isTableOfContentsMarker( $element )
                                      ) {
                                          // The element is a metadata element, that we allow to appear in
                                          // both inline and block contexts.
                              Severity: Critical
                              Found in includes/tidy/RemexCompatMunger.php - About 1 hr to fix

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

                                    public static function newFromIDs( $ids ) {
                                        $ids = array_map( 'intval', (array)$ids ); // paranoia
                                        if ( !$ids ) {
                                            // Database::select() doesn't like empty arrays
                                            return new ArrayIterator( [] );
                                Severity: Major
                                Found in includes/user/UserArray.php and 1 other location - About 1 hr to fix
                                includes/user/UserArray.php on lines 83..95

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

                                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

                                    private function getTargetAndType( ?string $par, WebRequest $request ) {
                                        $possibleTargets = [
                                            $request->getVal( 'wpTarget', null ),
                                            $par,
                                            $request->getVal( 'ip', null ),
                                Severity: Major
                                Found in includes/specials/SpecialUnblock.php and 1 other location - About 1 hr to fix
                                includes/specials/SpecialBlock.php on lines 840..857

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

                                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

                                    public static function newFromNames( $names ) {
                                        $names = array_map( 'strval', (array)$names ); // paranoia
                                        if ( !$names ) {
                                            // Database::select() doesn't like empty arrays
                                            return new ArrayIterator( [] );
                                Severity: Major
                                Found in includes/user/UserArray.php and 1 other location - About 1 hr to fix
                                includes/user/UserArray.php on lines 59..71

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

                                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 ( isset( $settings[self::PARAM_MAX_CHARS] ) && $len > $settings[self::PARAM_MAX_CHARS] ) {
                                            $this->failure(
                                                $this->failureMessage( 'maxchars', [
                                                    'maxbytes' => $settings[self::PARAM_MAX_BYTES] ?? null,
                                                    'maxchars' => $settings[self::PARAM_MAX_CHARS] ?? null,
                                Severity: Major
                                Found in includes/libs/ParamValidator/TypeDef/StringDef.php and 1 other location - About 1 hr to fix
                                includes/libs/ParamValidator/TypeDef/StringDef.php on lines 81..89

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

                                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

                                    protected function clearTempAccountCreationThrottle( string $ip ): void {
                                        $this->output( 'Clearing temp account creation throttle...' );
                                
                                        $tempAccountCreationThrottle = $this->getConfig()->get( MainConfigNames::TempAccountCreationThrottle );
                                        if ( !$tempAccountCreationThrottle ) {
                                Severity: Major
                                Found in maintenance/resetAuthenticationThrottle.php and 1 other location - About 1 hr to fix
                                maintenance/resetAuthenticationThrottle.php on lines 188..207

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

                                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