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

        $oouiNodes.each( function () {
            const data = $( this ).data( 'mw-modules' );
            if ( data ) {
                // We can trust this value, 'data-mw-*' attributes are banned from user content in Sanitizer
                const extraModules = data.split( ',' );
Severity: Major
Found in resources/src/mediawiki.htmlform/autoinfuse.js and 1 other location - About 1 hr to fix
resources/src/mediawiki.htmlform/cond-state.js on lines 184..191

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

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 (
        !this.isDisabled() &&
        !this.isFixed() &&
        ( e.keyCode === OO.ui.Keys.BACKSPACE || e.keyCode === OO.ui.Keys.DELETE )
    ) {
Severity: Major
Found in resources/lib/ooui/oojs-ui-widgets.js and 1 other location - About 1 hr to fix
resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js on lines 537..542

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

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 ( !this.stackLayout.isContinuous() && previousPage ) {
        // This should not be necessary, since any inputs on the previous page should have
        // been blurred when it was hidden, but browsers are not very consistent about
        // this.
        $focused = previousPage.$element.find( ':focus' );
Severity: Major
Found in resources/lib/ooui/oojs-ui-widgets.js and 1 other location - About 1 hr to fix
resources/lib/ooui/oojs-ui-widgets.js on lines 2955..2963

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

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

                        $( '<div>' ).addClass( 'suggestions-special' )
                            // Can't use click() because the container div is hidden when the
                            // textbox loses focus. Instead, listen for a mousedown followed
                            // by a mouseup on the same div.
                            .on( 'mousedown', ( e ) => {
Severity: Major
Found in resources/src/jquery/jquery.suggestions.js and 1 other location - About 1 hr to fix
resources/src/jquery/jquery.suggestions.js on lines 658..688

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

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 updateFieldsFromValue has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    mw.widgets.datetime.DateTimeInputWidget.prototype.updateFieldsFromValue = function () {
        let i, $field, spec, intercalary, sz;

        const date = this.getValueAsDate();

Severity: Minor
Found in resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js - About 1 hr to fix

    Function renderUploadForm has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        mw.ForeignStructuredUpload.BookletLayout.prototype.renderUploadForm = function () {
            let fieldset,
                layout = this;
    
            // These elements are filled with text in #initialize

      Function OoUiOutlineControlsWidget has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      OO.ui.OutlineControlsWidget = function OoUiOutlineControlsWidget( outline, config ) {
          // Allow passing positional parameters inside the config object
          if ( OO.isPlainObject( outline ) && config === undefined ) {
              config = outline;
              outline = config.outline;
      Severity: Minor
      Found in resources/lib/ooui/oojs-ui-widgets.js - About 1 hr to fix

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

            _setOption: function( key, value ) {
                var i,
                    valsLength = 0;
        
                if ( Array.isArray( this.options.values ) ) {
        Severity: Minor
        Found in resources/lib/jquery.ui/jquery.ui.slider.js - About 1 hr to fix

          Function Request has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function Request(input, options) {
              if (!(this instanceof Request)) {
                throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
              }
          
          
          Severity: Minor
          Found in resources/lib/fetch-polyfill/fetch.umd.js - About 1 hr to fix

            Method updateNotificationTimestamp has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function updateNotificationTimestamp(
                    UserIdentity $editor,
                    $target,
                    $timestamp
                ): array {
            Severity: Minor
            Found in includes/watchlist/WatchedItemStore.php - About 1 hr to fix

              Method getRedirectTarget has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getRedirectTarget( PageIdentity $page ): ?LinkTarget {
                      $cacheKey = self::makeCacheKey( $page );
                      $cachedValue = $this->procCache->get( $cacheKey );
                      if ( $cachedValue !== null ) {
                          return $cachedValue ?: null;
              Severity: Minor
              Found in includes/page/RedirectStore.php - About 1 hr to fix

                Method getEditButtons has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getEditButtons( &$tabindex ) {
                        $buttons = [];
                
                        $labelAsPublish =
                            $this->context->getConfig()->get( MainConfigNames::EditSubmitButtonLabelPublish );
                Severity: Minor
                Found in includes/editpage/EditPage.php - About 1 hr to fix

                  Method makeNewRevision has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function makeNewRevision(
                          CommentStoreComment $comment,
                          PageUpdateStatus $status
                      ) {
                          $title = $this->getTitle();
                  Severity: Minor
                  Found in includes/Storage/PageUpdater.php - About 1 hr to fix

                    Method getRenderedRevision has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function getRenderedRevision(
                            RevisionRecord $rev,
                            ParserOptions $options = null,
                            Authority $forPerformer = null,
                            array $hints = []
                    Severity: Minor
                    Found in includes/Revision/RevisionRenderer.php - About 1 hr to fix

                      Method validate has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function validate( $name, $value, array $settings, array $options ) {
                              static $codemap = [
                                  -42 => 'notupload', // Local from getValue()
                                  UPLOAD_ERR_FORM_SIZE => 'formsize',
                                  UPLOAD_ERR_PARTIAL => 'partial',
                      Severity: Minor
                      Found in includes/libs/ParamValidator/TypeDef/UploadDef.php - About 1 hr to fix

                        Method internalGetCount has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function internalGetCount(
                                $metricName,
                                EntityKey $entity,
                                MetricSpec $metricSpec,
                                SequenceSpec $seqSpec,
                        Severity: Minor
                        Found in includes/libs/WRStats/WRStatsReader.php - About 1 hr to fix

                          Method doGetFileStatMulti has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function doGetFileStatMulti( array $params ) {
                                  $stats = [];
                          
                                  $reqs = []; // (path => op)
                                  // (a) Check the containers of the paths...
                          Severity: Minor
                          Found in includes/libs/filebackend/SwiftFileBackend.php - About 1 hr to fix

                            Method get has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function get( $key, &$casToken = null ) {
                                    $getToken = ( func_num_args() >= 2 );
                            
                                    $this->_last_cmd_status = self::ERR_NONE;
                            
                            
                            Severity: Minor
                            Found in includes/libs/objectcache/utils/MemcachedClient.php - About 1 hr to fix

                              Method sourceStream has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function sourceStream(
                                      $fp,
                                      callable $lineCallback = null,
                                      callable $resultCallback = null,
                                      $fname = __METHOD__,
                              Severity: Minor
                              Found in includes/libs/rdbms/database/Database.php - About 1 hr to fix

                                Method updateBlock has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function updateBlock( DatabaseBlock $block ) {
                                        $this->logger->debug( 'Updating block; timestamp ' . $block->getTimestamp() );
                                
                                        $block->assertWiki( $this->wikiId );
                                
                                
                                Severity: Minor
                                Found in includes/block/DatabaseBlockStore.php - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language