wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Method formatRow has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function formatRow( $row ) {
        if ( $row->user_id == 0 ) { # T18487
            return '';
        }

Severity: Minor
Found in includes/specials/pagers/UsersPager.php - About 1 hr to fix

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

        public function execute( $mode ) {
            $this->setHeaders();
    
            $user = $this->getUser();
            if ( !$user->isRegistered()
    Severity: Minor
    Found in includes/specials/SpecialEditWatchlist.php - About 1 hr to fix

      Method makeForm has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function makeForm() {
              $fields = [
                  'Input' => [
                      'type' => 'textarea',
                      'label' => $this->msg( 'expand_templates_input' )->text(),
      Severity: Minor
      Found in includes/specials/SpecialExpandTemplates.php - About 1 hr to fix

        Method __construct has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function __construct(
                RevisionRecord $revRecord,
                ?RevisionRecord $previousRevRecord,
                bool $showRollbackLink,
                HookRunner $hookRunner,
        Severity: Minor
        Found in includes/specials/pagers/PagerTools.php - About 1 hr to fix

          Method handleError has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function handleError(
                  $level,
                  $message,
                  $file = null,
                  $line = null
          Severity: Minor
          Found in includes/exception/MWExceptionHandler.php - About 1 hr to fix

            Method getHeadLinksAlternateURLsArray has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function getHeadLinksAlternateURLsArray() {
                    $tags = [];
                    $languageUrls = [];
                    $action = $this->getContext()->getActionName();
                    $isCanonicalUrlAction = in_array( $action, [ 'history', 'info' ] );
            Severity: Minor
            Found in includes/Output/OutputPage.php - About 1 hr to fix

              Method claimOldest has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function claimOldest( $uuid ) {
                      $dbw = $this->getPrimaryDB();
              
                      $row = false; // the row acquired
                      do {
              Severity: Minor
              Found in includes/jobqueue/JobQueueDB.php - About 1 hr to fix

                Method maybeMakeExternalImage has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function maybeMakeExternalImage( $url ) {
                        $imagesfrom = $this->mOptions->getAllowExternalImagesFrom();
                        $imagesexception = (bool)$imagesfrom;
                        $text = false;
                        # $imagesfrom could be either a single string or an array of strings, parse out the latter
                Severity: Minor
                Found in includes/parser/Parser.php - About 1 hr to fix

                  Method pagesincategory has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function pagesincategory( $parser, $name = '', $arg1 = '', $arg2 = '' ) {
                          static $magicWords = null;
                          if ( $magicWords === null ) {
                              $magicWords = $parser->getMagicWordFactory()->newArray( [
                                  'pagesincategory_all',
                  Severity: Minor
                  Found in includes/parser/CoreParserFunctions.php - About 1 hr to fix

                    Method stripAltText has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function stripAltText( $caption, $holders ) {
                            # Strip bad stuff out of the title (tooltip).  We can't just use
                            # replaceLinkHoldersText() here, because if this function is called
                            # from handleInternalLinks2(), mLinkHolders won't be up-to-date.
                            if ( $holders ) {
                    Severity: Minor
                    Found in includes/parser/Parser.php - About 1 hr to fix

                      Method addUserToAutopromoteOnceGroups has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function addUserToAutopromoteOnceGroups(
                              UserIdentity $user,
                              string $event
                          ): array {
                              $user->assertWiki( $this->wikiId );
                      Severity: Minor
                      Found in includes/user/UserGroupManager.php - About 1 hr to fix

                        Method fileExistsBatch has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function fileExistsBatch( array $files ) {
                                $results = [];
                                foreach ( $files as $k => $f ) {
                                    if ( isset( $this->mFileExists[$f] ) ) {
                                        $results[$k] = $this->mFileExists[$f];
                        Severity: Minor
                        Found in includes/filerepo/ForeignAPIRepo.php - About 1 hr to fix

                          Method debugMsg has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function debugMsg( $str, $context = [] ) {
                                  global $wgDebugComments, $wgShowDebug;
                          
                                  if ( self::$enabled || $wgDebugComments || $wgShowDebug ) {
                                      if ( $context ) {
                          Severity: Minor
                          Found in includes/debug/MWDebug.php - About 1 hr to fix

                            Method doUpdates has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public static function doUpdates( $stage = self::ALL ) {
                                    /** @var ErrorPageError $guiError First presentable client-level error thrown */
                                    $guiError = null;
                                    /** @var Throwable $exception First of any error thrown */
                                    $exception = null;
                            Severity: Minor
                            Found in includes/deferred/DeferredUpdates.php - About 1 hr to fix

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

                                  public function execute() {
                                      if ( !( $this->hasOption( 'file' ) xor $this->hasOption( 'dump' ) ) ) {
                                          $this->fatalError( "You must provide a file or dump" );
                                      }
                              
                              
                              Severity: Minor
                              Found in maintenance/dumpIterator.php - About 1 hr to fix

                                Method getRowsOld has 45 lines of code (exceeds 25 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

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

                                      public function execute() {
                                          if ( $this->hasOption( 'tpl-time' ) ) {
                                              $this->templateTimestamp = wfTimestamp( TS_MW, strtotime( $this->getOption( 'tpl-time' ) ) );
                                              $hookContainer = $this->getHookContainer();
                                              $hookContainer->register( 'BeforeParserFetchTemplateRevisionRecord', [ $this, 'onFetchTemplate' ] );
                                  Severity: Minor
                                  Found in maintenance/benchmarks/benchmarkParse.php - About 1 hr to fix

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

                                        public function execute() {
                                            $siteStore = $this->getServiceContainer()->getSiteStore();
                                            if ( method_exists( $siteStore, 'reset' ) ) {
                                                // @phan-suppress-next-line PhanUndeclaredMethod
                                                $siteStore->reset();
                                    Severity: Minor
                                    Found in maintenance/addSite.php - About 1 hr to fix

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

                                          function makeRegexParser(regex) {
                                              return function() {
                                                  var matches = rule.substr(pos).match(regex);
                                      
                                                  if (matches === null) {
                                      Severity: Major
                                      Found in resources/lib/CLDRPluralRuleParser/CLDRPluralRuleParser.js and 2 other locations - About 1 hr to fix
                                      resources/lib/jquery.i18n/src/jquery.i18n.parser.js on lines 135..147
                                      resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js on lines 459..468

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

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

                                      OO.ui.WindowManager.prototype.isOpening = function ( win ) {
                                          return win === this.currentWindow && !!this.lifecycle &&
                                              this.lifecycle.isOpening();
                                      };
                                      Severity: Major
                                      Found in resources/lib/ooui/oojs-ui-windows.js and 2 other locations - About 1 hr to fix
                                      resources/lib/ooui/oojs-ui-windows.js on lines 1214..1217
                                      resources/lib/ooui/oojs-ui-windows.js on lines 1225..1228

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

                                      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