wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

    public function __construct(
        ApiMain $mainModule,
        $moduleName,
        MovePageFactory $movePageFactory,
        RepoGroup $repoGroup,
Severity: Major
Found in includes/api/ApiMove.php and 2 other locations - About 2 hrs to fix
includes/api/ApiDelete.php on lines 61..79
includes/api/ApiUserrights.php on lines 63..81

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

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

    public function __construct(
        ApiMain $mainModule,
        $moduleName,
        RepoGroup $repoGroup,
        WatchlistManager $watchlistManager,
Severity: Major
Found in includes/api/ApiDelete.php and 2 other locations - About 2 hrs to fix
includes/api/ApiMove.php on lines 46..65
includes/api/ApiUserrights.php on lines 63..81

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

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

    public function __construct(
        ApiMain $mainModule,
        $moduleName,
        UserGroupManager $userGroupManager,
        WatchedItemStoreInterface $watchedItemStore,
Severity: Major
Found in includes/api/ApiUserrights.php and 2 other locations - About 2 hrs to fix
includes/api/ApiDelete.php on lines 61..79
includes/api/ApiMove.php on lines 46..65

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

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['endsortkeyprefix'] !== null ) {
                    $endsortkey = $this->collation->getSortKey( $params['endsortkeyprefix'] );
                } elseif ( $params['endhexsortkey'] !== null ) {
                    if ( !$this->validateHexSortkey( $params['endhexsortkey'] ) ) {
                        $encParamName = $this->encodeParamName( 'endhexsortkey' );
Severity: Major
Found in includes/api/ApiQueryCategoryMembers.php and 1 other location - About 2 hrs to fix
includes/api/ApiQueryCategoryMembers.php on lines 163..173

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

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

Method __construct has 21 arguments (exceeds 4 allowed). Consider refactoring.
Open

        ServiceOptions $svcOptions,
        MagicWordFactory $magicWordFactory,
        Language $contLang,
        UrlUtils $urlUtils,
        SpecialPageFactory $spFactory,
Severity: Major
Found in includes/parser/ParserFactory.php - About 2 hrs to fix

    File NamespaceInfo.php has 276 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Provide things related to namespaces.
     *
     * This program is free software; you can redistribute it and/or modify
    Severity: Minor
    Found in includes/title/NamespaceInfo.php - About 2 hrs to fix

      File refreshLinks.php has 276 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 maintenance/refreshLinks.php - About 2 hrs to fix

        Function showTemplates has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function showTemplates( templates ) {
                // The .templatesUsed div can be empty, if no templates are in use.
                // In that case, we have to create the required structure.
                const $parent = $( '.templatesUsed' );
        
        
        Severity: Major
        Found in resources/src/mediawiki.page.preview.js - About 2 hrs to fix

          Function renderInfoForm has 65 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              mw.ForeignStructuredUpload.BookletLayout.prototype.renderInfoForm = function () {
                  let fieldset;
          
                  this.filePreview = new OO.ui.Widget( {
                      classes: [ 'mw-upload-bookletLayout-filePreview' ]

            Function superMatcher has 65 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    superMatcher = function( seed, context, xml, results, outermost ) {
                        var elem, j, matcher,
                            matchedCount = 0,
                            i = "0",
                            unmatched = seed && [],
            Severity: Major
            Found in resources/lib/jquery/jquery.js - About 2 hrs to fix

              Method loadRestrictions has 65 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function loadRestrictions(
                      PageIdentity $page, int $flags = IDBAccessObject::READ_NORMAL
                  ): void {
                      $page->assertWiki( PageIdentity::LOCAL );
              
              
              Severity: Major
              Found in includes/Permissions/RestrictionStore.php - About 2 hrs to fix

                Method importFormData has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function importFormData( &$request ) {
                        # Section edit can come from either the form or a link
                        $this->section = $request->getVal( 'wpSection', $request->getVal( 'section', '' ) );
                
                        if ( $this->section !== null && $this->section !== '' && !$this->isSectionEditSupported() ) {
                Severity: Major
                Found in includes/editpage/EditPage.php - About 2 hrs to fix

                  Method shiftBoundaries has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function shiftBoundaries( array $lines, array &$changed, array $other_changed ) {
                          $i = 0;
                          $j = 0;
                  
                          assert( count( $lines ) == count( $changed ) );
                  Severity: Major
                  Found in includes/libs/Diff/DiffEngine.php - About 2 hrs to fix

                    Method doStoreInternal has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function doStoreInternal( array $params ) {
                            $status = $this->newStatus();
                    
                            [ $dstCont, $dstRel ] = $this->resolveStoragePathReal( $params['dst'] );
                            if ( $dstRel === null ) {
                    Severity: Major
                    Found in includes/libs/filebackend/SwiftFileBackend.php - About 2 hrs to fix

                      Method trySubmit has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function trySubmit() {
                              $valid = true;
                              $hoistedErrors = Status::newGood();
                              if ( $this->mValidationErrorMessage ) {
                                  foreach ( $this->mValidationErrorMessage as $error ) {
                      Severity: Major
                      Found in includes/htmlform/HTMLForm.php - About 2 hrs to fix

                        Method editingPreferences has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function editingPreferences( User $user, MessageLocalizer $l10n, &$defaultPreferences ) {
                                $defaultPreferences['editsectiononrightclick'] = [
                                    'type' => 'toggle',
                                    'section' => 'editing/advancedediting',
                                    'label-message' => 'tog-editsectiononrightclick',
                        Severity: Major
                        Found in includes/preferences/DefaultPreferencesFactory.php - About 2 hrs to fix

                          Method initLanguage has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function initLanguage( $code ) {
                                  if ( isset( $this->initialisedLangs[$code] ) ) {
                                      return;
                                  }
                          
                          
                          Severity: Major
                          Found in includes/language/LocalisationCache.php - About 2 hrs to fix

                            Method run has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function run() {
                                    $dbw = $this->lbFactory->getPrimaryDatabase();
                                    $ticket = $this->lbFactory->getEmptyTransactionTicket( __METHOD__ );
                                    $table = $this->params['table'];
                                    $column = $this->params['column'];
                            Severity: Major
                            Found in includes/RenameUser/RenameUserJob.php - About 2 hrs to fix

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

                                  public function execute( $subpage ) {
                                      $this->rcSubpage = $subpage;
                              
                                      if ( $this->considerActionsForDefaultSavedQuery( $subpage ) ) {
                                          // Don't bother rendering the page if we'll be performing a redirect (T330100).
                              Severity: Major
                              Found in includes/specialpage/ChangesListSpecialPage.php - About 2 hrs to fix

                                File ApiQueryFilearchive.php has 275 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                <?php
                                /**
                                 * API for MediaWiki 1.12+
                                 *
                                 * Copyright © 2010 Sam Reed
                                Severity: Minor
                                Found in includes/api/ApiQueryFilearchive.php - About 2 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language