wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

    public function __construct( StatsStore $store, $specs, $prefix ) {
        $this->store = $store;
        $this->metricSpecs = [];
        foreach ( $specs as $name => $spec ) {
            $this->metricSpecs[$name] = new MetricSpec( $spec );
Severity: Major
Found in includes/libs/WRStats/WRStatsWriter.php and 1 other location - About 2 hrs to fix
includes/libs/WRStats/WRStatsReader.php on lines 31..42

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

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 const APPLY_DEFAULT_CONFIG_OPTIONS = [
        MainConfigNames::DBcompress,
        MainConfigNames::DBDefaultGroup,
        MainConfigNames::DBmwschema,
        MainConfigNames::DBname,
Severity: Major
Found in includes/db/MWLBFactory.php and 1 other location - About 2 hrs to fix
includes/parser/ParserOutputFlags.php on lines 192..213

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

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

        return [
            self::NO_GALLERY,
            self::ENABLE_OOUI,
            self::INDEX_POLICY,
            self::NO_INDEX_POLICY,
Severity: Major
Found in includes/parser/ParserOutputFlags.php and 1 other location - About 2 hrs to fix
includes/db/MWLBFactory.php on lines 55..76

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

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

Function highlight has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function highlight( context, $result, updateTextbox ) {
        const $selected = context.data.$container.find( '.suggestions-result-current' );
        if ( !$result.get || $selected.get( 0 ) !== $result.get( 0 ) ) {
            if ( $result === 'prev' ) {
                // eslint-disable-next-line no-jquery/no-class-state
Severity: Major
Found in resources/src/jquery/jquery.suggestions.js - About 2 hrs to fix

    Function textSelection has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        $.fn.textSelection = function ( command, commandOptions ) {
            const alternateFn = $( this ).data( 'jquery.textSelection' );
    
            // Prevent values of `undefined` overwriting defaults (T368102)
            for ( const key in commandOptions ) {
    Severity: Major
    Found in resources/src/jquery/jquery.textSelection.js - About 2 hrs to fix

      Function onModelInitialize has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ChangesLimitAndDateButtonWidget.prototype.onModelInitialize = function () {
          const displayGroupModel = this.model.getGroup( 'display' );
      
          this.limitGroupModel = this.model.getGroup( 'limit' );
          this.groupByPageItemModel = displayGroupModel.getItemByParamName( 'enhanced' );

        Function runScript has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                var runScript = function () {
                    $CODE.profileScriptStart();
                    var script = registry[ module ].script;
                    var markModuleReady = function () {
                        $CODE.profileScriptEnd();
        Severity: Major
        Found in resources/src/startup/mediawiki.loader.js - About 2 hrs to fix

          Function translate has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function translate(number, withoutSuffix, key, isFuture) {
                  var result = number + ' ';
                  switch (key) {
                      case 's': // a few seconds / in a few seconds / a few seconds ago
                          return withoutSuffix || isFuture ? 'pár sekund' : 'pár sekundami';
          Severity: Major
          Found in resources/lib/moment/locale/cs.js - About 2 hrs to fix

            Function translate has 51 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function translate(number, withoutSuffix, key, isFuture) {
                    var result = number + ' ';
                    switch (key) {
                        case 's': // a few seconds / in a few seconds / a few seconds ago
                            return withoutSuffix || isFuture ? 'pár sekúnd' : 'pár sekundami';
            Severity: Major
            Found in resources/lib/moment/locale/sk.js - About 2 hrs to fix

              Function buildFragment has 51 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function buildFragment( elems, context, scripts, selection, ignored ) {
                  var elem, tmp, tag, wrap, attached, j,
                      fragment = context.createDocumentFragment(),
                      nodes = [],
                      i = 0,
              Severity: Major
              Found in resources/lib/jquery/jquery.js - About 2 hrs to fix

                Function _setOption has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    _setOption: function( key, value ) {
                        var isDraggable, isResizable,
                            uiDialog = this.uiDialog;
                
                        switch ( key ) {
                Severity: Major
                Found in resources/lib/jquery.ui/jquery.ui.dialog.js - About 2 hrs to fix

                  Method addComponentFiles has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function addComponentFiles( Context $context ) {
                          $codexFiles = $this->getCodexFiles( $context );
                  
                          $requestedFiles = array_map( static function ( $component ) use ( $codexFiles ) {
                              if ( !isset( $codexFiles[ 'components' ][ $component ] ) ) {
                  Severity: Major
                  Found in includes/ResourceLoader/CodexModule.php - About 2 hrs to fix

                    Method addUserWarnings has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function addUserWarnings(
                            IntroMessageList $messages,
                            MessageLocalizer $localizer,
                            Title $title,
                            Authority $performer
                    Severity: Major
                    Found in includes/editpage/IntroMessageBuilder.php - About 2 hrs to fix

                      Method addHeader has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function addHeader( $diff, $otitle, $ntitle, $multi = '', $notice = '' ) {
                              // shared.css sets diff in interface language/dir, but the actual content
                              // is often in a different language, mostly the page content language/dir
                              $header = Html::openElement( 'table', [
                                  'class' => [
                      Severity: Major
                      Found in includes/diff/DifferenceEngine.php - About 2 hrs to fix

                        Method getKnownCurrentRevision has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function getKnownCurrentRevision( PageIdentity $page, $revId = 0 ) {
                                $db = $this->getReplicaConnection();
                                $revIdPassed = $revId;
                                $pageId = $this->getArticleId( $page );
                                if ( !$pageId ) {
                        Severity: Major
                        Found in includes/Revision/RevisionStore.php - About 2 hrs to fix

                          Method normalizeRequests has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function normalizeRequests( array &$reqs ) {
                                  foreach ( $reqs as &$req ) {
                                      $req['response'] = [
                                          'code'     => 0,
                                          'reason'   => '',
                          Severity: Major
                          Found in includes/libs/http/MultiHttpClient.php - About 2 hrs to fix

                            Method get_multi has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function get_multi( $keys ) {
                                    $this->_last_cmd_status = self::ERR_NONE;
                            
                                    if ( !$this->_active ) {
                                        $this->_last_cmd_status = self::ERR_UNEXPECTED;
                            Severity: Major
                            Found in includes/libs/objectcache/utils/MemcachedClient.php - About 2 hrs to fix

                              Method duplicateTableStructure has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function duplicateTableStructure(
                                      $oldName, $newName, $temporary = false, $fname = __METHOD__
                                  ) {
                                      $newNameE = $this->platform->addIdentifierQuotes( $newName );
                                      $oldNameE = $this->platform->addIdentifierQuotes( $oldName );
                              Severity: Major
                              Found in includes/libs/rdbms/database/DatabasePostgres.php - About 2 hrs to fix

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

                                    public function __construct( array $params ) {
                                        $this->logger = $params['logger'] ?? new NullLogger();
                                        $this->transactionManager = new TransactionManager(
                                            $this->logger,
                                            $params['trxProfiler']
                                Severity: Major
                                Found in includes/libs/rdbms/database/Database.php - About 2 hrs to fix

                                  Method transactionWritingOut has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function transactionWritingOut(
                                          $server,
                                          $db,
                                          string $id,
                                          float $writeTime,
                                  Severity: Major
                                  Found in includes/libs/rdbms/TransactionProfiler.php - About 2 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language