wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Method exportExtractedData has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function exportExtractedData( array $info ) {
        if ( $info['globals'] ) {
            // Create a copy of the keys to allow fast access via isset also for null values
            // Since php8.1 always a read-only copy is created when the whole object is passed on function calls
            // (like for array_key_exists). See T366547 - https://wiki.php.net/rfc/restrict_globals_usage
Severity: Major
Found in includes/registration/ExtensionRegistry.php - About 3 hrs to fix

    Method executeInternal has 83 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function executeInternal( $isDryRun ) {
            $generatorName = $this->mAllowGenerator ? $this->mParams['generator'] : null;
            if ( isset( $generatorName ) ) {
                $dbSource = $this->mDbSource;
                if ( !$dbSource instanceof ApiQuery ) {
    Severity: Major
    Found in includes/api/ApiPageSet.php - About 3 hrs to fix

      Method outputChangesList has 83 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function outputChangesList( $rows, $opts ) {
              $dbr = $this->getDB();
              $user = $this->getUser();
              $output = $this->getOutput();
      
      
      Severity: Major
      Found in includes/specials/SpecialWatchlist.php - About 3 hrs to fix

        Method makeNamespaceRow has 83 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function makeNamespaceRow( int $ns, string $localName ): string {
                $canonicalName = $this->namespaceInfo->getCanonicalName( $ns );
                if ( $canonicalName ) {
                    $canonicalName = strtr( $canonicalName, '_', ' ' );
                } else {
        Severity: Major
        Found in includes/specials/SpecialNamespaceInfo.php - About 3 hrs to fix

          Method reformat has 83 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function reformat( $preference, $text, $options = [] ) {
                  $userFormatId = self::PREFERENCE_IDS[$preference] ?? self::NONE;
                  foreach ( self::TARGET_FORMATS as $source => $_ ) {
                      if ( isset( self::RULES[$userFormatId][$source] ) ) {
                          # Specific rules
          Severity: Major
          Found in includes/parser/DateFormatter.php - About 3 hrs to fix

            File MessagesNb.php has 305 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            /** Norwegian Bokmål (norsk bokmål)
             *
             * @file
             * @ingroup Languages
            Severity: Minor
            Found in languages/messages/MessagesNb.php - About 3 hrs to fix

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

                  public function __construct(
                      LinkRenderer $linkRenderer,
                      LinkBatchFactory $linkBatchFactory,
                      LinkCache $linkCache,
                      RepoGroup $repoGroup,
              Severity: Major
              Found in includes/CommentFormatter/CommentParserFactory.php and 1 other location - About 3 hrs to fix
              includes/import/WikiImporterFactory.php on lines 48..68

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

              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 function __construct(
                      Config $config,
                      HookContainer $hookContainer,
                      Language $contentLanguage,
                      NamespaceInfo $namespaceInfo,
              Severity: Major
              Found in includes/import/WikiImporterFactory.php and 1 other location - About 3 hrs to fix
              includes/CommentFormatter/CommentParserFactory.php on lines 48..68

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

              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

              ChangesLimitAndDateButtonWidget.prototype.onPopupDays = function ( filterName ) {
                  const item = this.daysGroupModel.getItemByName( filterName );
              
                  this.controller.toggleFilterSelect( filterName, true );
                  this.controller.updateDaysDefault( item.getParamName() );
              resources/src/mediawiki.rcfilters/ui/ChangesLimitAndDateButtonWidget.js on lines 137..143

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

              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

              ChangesLimitAndDateButtonWidget.prototype.onPopupLimit = function ( filterName ) {
                  const item = this.limitGroupModel.getItemByName( filterName );
              
                  this.controller.toggleFilterSelect( filterName, true );
                  this.controller.updateLimitDefault( item.getParamName() );
              resources/src/mediawiki.rcfilters/ui/ChangesLimitAndDateButtonWidget.js on lines 169..175

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

              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 UploadFromChunks.php has 304 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              use MediaWiki\Deferred\AutoCommitUpdate;
              use MediaWiki\Deferred\DeferredUpdates;
              use MediaWiki\Logger\LoggerFactory;
              Severity: Minor
              Found in includes/upload/UploadFromChunks.php - About 3 hrs to fix

                Function diffBisect has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    DiffMatchPatch.prototype.diffBisect = function (text1, text2, deadline) {
                      var text1Length, text2Length, maxD, vOffset, vLength, v1, v2, x, delta, front, k1start, k1end, k2start, k2end, k2Offset, k1Offset, x1, x2, y1, y2, d, k1, k2;
                
                      // Cache the text lengths to prevent multiple calls.
                      text1Length = text1.length;
                Severity: Major
                Found in resources/lib/qunitjs/qunit.js - About 3 hrs to fix

                  Method doDelete has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function doDelete(
                          Title $title,
                          LocalFile $file,
                          ?string $oldimage,
                          $reason,
                  Severity: Major
                  Found in includes/page/File/FileDeleteForm.php - About 3 hrs to fix

                    Method getLocksOnServer has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function getLocksOnServer( $lockSrv, array $pathsByType ) {
                            $status = StatusValue::newGood();
                    
                            $pathList = array_merge( ...array_values( $pathsByType ) );
                    
                    
                    Severity: Major
                    Found in includes/libs/lockmanager/RedisLockManager.php - About 3 hrs to fix

                      Method reallyOpenConnection has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function reallyOpenConnection( $i, DatabaseDomain $domain, array $lbInfo ) {
                              if ( $this->disabled ) {
                                  throw new DBAccessError();
                              }
                      
                      
                      Severity: Major
                      Found in includes/libs/rdbms/loadbalancer/LoadBalancer.php - About 3 hrs to fix

                        Method getPageList has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function getPageList(): array {
                                if ( !is_array( $this->list ) ) {
                                    $this->list = self::CORE_LIST;
                        
                                    if ( !$this->options->get( MainConfigNames::DisableInternalSearch ) ) {
                        Severity: Major
                        Found in includes/specialpage/SpecialPageFactory.php - About 3 hrs to fix

                          Method execute has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function execute( $par ) {
                                  $this->checkPermissions();
                          
                                  $this->setHeaders();
                                  $this->outputHeader();
                          Severity: Major
                          Found in includes/specialpage/QueryPage.php - About 3 hrs to fix

                            Method setupDatabase has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function setupDatabase() {
                                    $dir = $this->getVar( 'wgSQLiteDataDir' );
                            
                                    # Double check (Only available in web installation). We checked this before but maybe someone
                                    # deleted the data dir between then and now
                            Severity: Major
                            Found in includes/installer/SqliteInstaller.php - About 3 hrs to fix

                              Method __wakeup has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function __wakeup() {
                                      $oldAliases = [
                                          // This was the pre-namespace name of the class, which is still
                                          // used in pre-1.42 serialized objects.
                                          'ParserOutput',
                              Severity: Major
                              Found in includes/parser/ParserOutput.php - About 3 hrs to fix

                                Method getMessageParameters has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    protected function getMessageParameters() {
                                        $params = parent::getMessageParameters();
                                
                                        $title = $this->entry->getTarget();
                                        if ( substr( $title->getText(), 0, 1 ) === '#' ) {
                                Severity: Major
                                Found in includes/logging/BlockLogFormatter.php - About 3 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language