wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

    public const CONSTRUCTOR_OPTIONS = [
        MainConfigNames::GalleryOptions,
        MainConfigNames::AllowExternalImages,
        MainConfigNames::AllowExternalImagesFrom,
        MainConfigNames::Server,
Severity: Major
Found in includes/parser/Parsoid/Config/SiteConfig.php and 1 other location - About 3 hrs to fix
includes/parser/Parser.php on lines 417..443

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

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

    final public function createInternal( array $params ) {
        /** @noinspection PhpUnusedLocalVariableInspection */
        $ps = $this->scopedProfileSection( __METHOD__ . "-{$this->name}" );

        if ( strlen( $params['content'] ) > $this->maxFileSizeInternal() ) {
Severity: Major
Found in includes/libs/filebackend/FileBackendStore.php and 1 other location - About 3 hrs to fix
includes/libs/filebackend/FileBackendStore.php on lines 184..200

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

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 createSerialMapping(): SerialMapping {
        $type = $this->serialMappingConfig['type'];
        if ( isset( self::SERIAL_MAPPINGS[$type] ) ) {
            $spec = self::SERIAL_MAPPINGS[$type];
        } else {
Severity: Major
Found in includes/user/TempUser/TempUserCreator.php and 1 other location - About 3 hrs to fix
includes/user/TempUser/TempUserCreator.php on lines 267..290

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

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

    final public function storeInternal( array $params ) {
        /** @noinspection PhpUnusedLocalVariableInspection */
        $ps = $this->scopedProfileSection( __METHOD__ . "-{$this->name}" );

        if ( filesize( $params['src'] ) > $this->maxFileSizeInternal() ) {
Severity: Major
Found in includes/libs/filebackend/FileBackendStore.php and 1 other location - About 3 hrs to fix
includes/libs/filebackend/FileBackendStore.php on lines 141..157

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

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 createSerialProvider(): SerialProvider {
        $type = $this->serialProviderConfig['type'];
        if ( isset( self::SERIAL_PROVIDERS[$type] ) ) {
            $spec = self::SERIAL_PROVIDERS[$type];
        } else {
Severity: Major
Found in includes/user/TempUser/TempUserCreator.php and 1 other location - About 3 hrs to fix
includes/user/TempUser/TempUserCreator.php on lines 307..329

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

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 CONSTRUCTOR_OPTIONS = [
        // See documentation for the corresponding config options
        // Many of these are only used in (eg) CoreMagicVariables
        MainConfigNames::AllowDisplayTitle,
        MainConfigNames::AllowSlowParserFunctions,
Severity: Major
Found in includes/parser/Parser.php and 1 other location - About 3 hrs to fix
includes/parser/Parsoid/Config/SiteConfig.php on lines 76..100

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

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 MemcachedPeclBagOStuff.php has 298 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 includes/libs/objectcache/MemcachedPeclBagOStuff.php - About 3 hrs to fix

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

        mw.widgets.SizeFilterWidget.prototype.restorePreInfuseState = function ( state ) {
            mw.widgets.SizeFilterWidget.super.prototype.restorePreInfuseState.call( this, state );
            this.radioselectinput.restorePreInfuseState( state.radioselectinput );
            this.textinput.restorePreInfuseState( state.textinput );
        };
    resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.js on lines 101..105
    resources/src/mediawiki.widgets/mw.widgets.SelectWithInputWidget.js on lines 116..120

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

    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

    OO.ui.MenuSelectWidget.prototype.unbindDocumentKeyDownListener = function () {
        if ( this.$input ) {
            this.$input.off( 'keydown', this.onDocumentKeyDownHandler );
        } else {
            OO.ui.MenuSelectWidget.super.prototype.unbindDocumentKeyDownListener.call( this );
    Severity: Major
    Found in resources/lib/ooui/oojs-ui-core.js and 1 other location - About 3 hrs to fix
    resources/lib/ooui/oojs-ui-core.js on lines 8623..8629

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

    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

        mw.widgets.ComplexTitleInputWidget.prototype.restorePreInfuseState = function ( state ) {
            mw.widgets.ComplexTitleInputWidget.super.prototype.restorePreInfuseState.call( this, state );
            this.namespace.restorePreInfuseState( state.namespace );
            this.title.restorePreInfuseState( state.title );
        };
    resources/src/mediawiki.widgets/mw.widgets.SelectWithInputWidget.js on lines 116..120
    resources/src/mediawiki.widgets/mw.widgets.SizeFilterWidget.js on lines 104..108

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

    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

    OO.ui.MenuSelectWidget.prototype.bindDocumentKeyDownListener = function () {
        if ( this.$input ) {
            this.$input.on( 'keydown', this.onDocumentKeyDownHandler );
        } else {
            OO.ui.MenuSelectWidget.super.prototype.bindDocumentKeyDownListener.call( this );
    Severity: Major
    Found in resources/lib/ooui/oojs-ui-core.js and 1 other location - About 3 hrs to fix
    resources/lib/ooui/oojs-ui-core.js on lines 8634..8640

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

    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

        mw.widgets.SelectWithInputWidget.prototype.restorePreInfuseState = function ( state ) {
            mw.widgets.SelectWithInputWidget.super.prototype.restorePreInfuseState.call( this, state );
            this.dropdowninput.restorePreInfuseState( state.dropdowninput );
            this.textinput.restorePreInfuseState( state.textinput );
        };
    resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.js on lines 101..105
    resources/src/mediawiki.widgets/mw.widgets.SizeFilterWidget.js on lines 104..108

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

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

    <?php
    
    namespace MediaWiki\Rest\Handler\Helper;
    
    use MediaWiki\ChangeTags\ChangeTagsStore;
    Severity: Minor
    Found in includes/Rest/Handler/Helper/PageContentHelper.php - About 3 hrs to fix

      File SearchFormWidget.php has 297 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace MediaWiki\Search\SearchWidgets;
      
      use MediaWiki\Config\ServiceOptions;
      Severity: Minor
      Found in includes/search/searchwidgets/SearchFormWidget.php - About 3 hrs to fix

        Function find has 78 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function find( selector, context, results, seed ) {
            var m, i, elem, nid, match, groups, newSelector,
                newContext = context && context.ownerDocument,
        
                // nodeType defaults to 9, since context defaults to document
        Severity: Major
        Found in resources/lib/jquery/jquery.js - About 3 hrs to fix

          Function onDocumentKeyDown has 78 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          OO.ui.SelectWidget.prototype.onDocumentKeyDown = function ( e ) {
              let handled = false;
          
              const currentItem =
                  ( this.isVisible() && this.findHighlightedItem() ) ||
          Severity: Major
          Found in resources/lib/ooui/oojs-ui-core.js - About 3 hrs to fix

            Method respond has 78 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function respond( Context $context ) {
                    // Buffer output to catch warnings. Normally we'd use ob_clean() on the
                    // top-level output buffer to clear warnings, but that breaks when ob_gzhandler
                    // is used: ob_clean() will clear the GZIP header in that case and it won't come
                    // back for subsequent output, resulting in invalid GZIP. So we have to wrap
            Severity: Major
            Found in includes/ResourceLoader/ResourceLoader.php - About 3 hrs to fix

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

                  public function duplicateTableStructure(
                      $oldName, $newName, $temporary = false, $fname = __METHOD__
                  ) {
                      $query = new Query(
                          "SELECT sql FROM sqlite_master WHERE tbl_name=" .
              Severity: Major
              Found in includes/libs/rdbms/database/DatabaseSqlite.php - About 3 hrs to fix

                Method onView has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function onView() {
                        $this->getOutput()->disable();
                        $request = $this->getRequest();
                        $response = $request->response();
                        $config = $this->context->getConfig();
                Severity: Major
                Found in includes/actions/RawAction.php - About 3 hrs to fix

                  Method setupUser has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function setupUser() {
                          $dbUser = $this->getVar( 'wgDBuser' );
                          if ( $dbUser == $this->getVar( '_InstallUser' ) ) {
                              return Status::newGood();
                          }
                  Severity: Major
                  Found in includes/installer/MysqlInstaller.php - About 3 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language