wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 912 of 912 total issues

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

    this.heightsInput = new OO.ui.NumberInputWidget( {
        min: 0,
        showButtons: false,
        input: {
            placeholder: ve.msg( 'visualeditor-mwgallerydialog-heights-input-placeholder', this.defaults.imageHeight )
Severity: Major
Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js and 1 other location - About 1 hr to fix
modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js on lines 294..300

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

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

ve.dm.MWGalleryNode.static.getHashObject = function ( dataElement ) {
    return {
        type: dataElement.type,
        mw: ve.copy( dataElement.attributes.mw )
    };
Severity: Major
Found in modules/ve-mw/dm/nodes/ve.dm.MWGalleryNode.js and 1 other location - About 1 hr to fix
modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js on lines 131..136

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

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

Consider simplifying this complex logical expression.
Open

        if (
            pageCanLoadEditor &&
            showWikitextWelcome &&
            // At least one editor is available (T201928)
            ( init.isVisualAvailable || init.isWikitextAvailable || $( '#wpTextbox1' ).length ) &&
Severity: Critical
Found in modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js - About 1 hr to fix

    Function onWindowPopState has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    ve.init.mw.DesktopArticleTarget.prototype.onWindowPopState = function ( e ) {
        if ( !this.verifyPopState( e.state ) ) {
            // Ignore popstate events fired for states not created by us
            // This also filters out the initial fire in Chrome (T59901).
            return;
    Severity: Minor
    Found in modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js - About 1 hr to fix

      Function preparedCacheKeyPromise has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              .then( ( deflatedHtml ) => {
                  if ( aborted ) {
                      return ve.createDeferred().reject();
                  }
                  xhr = this.getContentApi().postWithToken( 'csrf',
      Severity: Minor
      Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 1 hr to fix

        Function parseDocument has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ve.init.mw.Target.static.parseDocument = function ( documentString, mode, section, onlySection ) {
            let doc;
            if ( mode === 'source' ) {
                // Parent method
                doc = ve.init.mw.Target.super.static.parseDocument.call( this, documentString, mode );
        Severity: Minor
        Found in modules/ve-mw/init/targets/ve.init.mw.Target.js - About 1 hr to fix

          Function onHighlightItem has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          ve.ui.MWGalleryDialog.prototype.onHighlightItem = function ( item ) {
              // Unhighlight previous item
              if ( this.highlightedItem ) {
                  this.highlightedItem.toggleHighlighted( false );
              }
          Severity: Minor
          Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js - About 1 hr to fix

            Function updateImageNode has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            ve.dm.MWImageModel.prototype.updateImageNode = function ( node, surfaceModel ) {
                const doc = surfaceModel.getDocument();
            
                // Update the caption
                if ( node.getType() === 'mwBlockImage' ) {
            Severity: Minor
            Found in modules/ve-mw/dm/models/ve.dm.MWImageModel.js - About 1 hr to fix

              Function VeUiMWGalleryItemWidget has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              ve.ui.MWGalleryItemWidget = function VeUiMWGalleryItemWidget( imageInfo, config ) {
                  this.resource = imageInfo.resource;
                  this.altText = imageInfo.altText || '';
                  this.altTextSame = imageInfo.altTextSame;
                  this.href = imageInfo.href;
              Severity: Minor
              Found in modules/ve-mw/ui/widgets/ve.ui.MWGalleryItemWidget.js - About 1 hr to fix

                Function onCopy has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                ve.ce.MWWikitextSurface.prototype.onCopy = function ( e ) {
                    const clipboardData = e.originalEvent.clipboardData,
                        text = this.getModel().getFragment().getText( true ).replace( /\n\n/g, '\n' );
                
                    if ( !text ) {
                Severity: Minor
                Found in modules/ve-mw/ce/ve.ce.MWWikitextSurface.js - About 1 hr to fix

                  Function VeCeMWInlineImageNode has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  ve.ce.MWInlineImageNode = function VeCeMWInlineImageNode( model, config ) {
                      let $image;
                      let hasHref = false;
                  
                      if ( model.getAttribute( 'isError' ) ) {
                  Severity: Minor
                  Found in modules/ve-mw/ce/nodes/ve.ce.MWInlineImageNode.js - About 1 hr to fix

                    Method onCustomEditor has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function onCustomEditor( $article, $user ) {
                            $req = $article->getContext()->getRequest();
                            $services = MediaWikiServices::getInstance();
                            $urlUtils = $services->getUrlUtils();
                            $veConfig = $services->getConfigFactory()->makeConfig( 'visualeditor' );
                    Severity: Minor
                    Found in includes/Hooks.php - About 1 hr to fix

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

                          for ( const key in params ) {
                              $form.append( $( '<input>' ).attr( { type: 'hidden', name: key, value: params[ key ] } ) );
                          }
                      Severity: Major
                      Found in modules/ve-mw-collab/ve.ui.MWExportWikitextDialog.js and 1 other location - About 1 hr to fix
                      modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js on lines 1681..1683

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

                      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

                      ve.init.mw.GalleryImageInfoCache = function VeInitMwGalleryImageInfoCache() {
                          // Parent constructor
                          ve.init.mw.GalleryImageInfoCache.super.apply( this, arguments );
                      };
                      modules/ve-mw/init/apiresponsecache/ve.init.mw.ImageInfoCache.js on lines 16..19
                      modules/ve-mw/init/apiresponsecache/ve.init.mw.LinkCache.js on lines 16..19

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

                      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

                      ve.init.mw.ImageInfoCache = function VeInitMwImageInfoCache() {
                          // Parent constructor
                          ve.init.mw.ImageInfoCache.super.apply( this, arguments );
                      };
                      modules/ve-mw/init/apiresponsecache/ve.init.mw.GalleryImageInfoCache.js on lines 16..19
                      modules/ve-mw/init/apiresponsecache/ve.init.mw.LinkCache.js on lines 16..19

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

                      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

                      ve.init.mw.LinkCache = function VeInitMwLinkCache() {
                          // Parent constructor
                          ve.init.mw.LinkCache.super.apply( this, arguments );
                      };
                      modules/ve-mw/init/apiresponsecache/ve.init.mw.GalleryImageInfoCache.js on lines 16..19
                      modules/ve-mw/init/apiresponsecache/ve.init.mw.ImageInfoCache.js on lines 16..19

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

                      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

                      ve.dm.MWNoContentConvertMetaItem.static.toDataElement = function ( domElements ) {
                          // HACK: Don't rely on Parsoid always putting the RDFa type as a property
                          return {
                              type: this.name,
                              originalProperty: domElements[ 0 ].getAttribute( 'property' )
                      modules/ve-mw/dm/metaitems/ve.dm.MWNoTitleConvertMetaItem.js on lines 35..41

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

                      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

                      ve.dm.MWNoTitleConvertMetaItem.static.toDataElement = function ( domElements ) {
                          // HACK: Don't rely on Parsoid always putting the RDFa type as a property
                          return {
                              type: this.name,
                              originalProperty: domElements[ 0 ].getAttribute( 'property' )
                      modules/ve-mw/dm/metaitems/ve.dm.MWNoContentConvertMetaItem.js on lines 35..41

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

                      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

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

                          for ( const key in params ) {
                              $form.append( $( '<input>' ).attr( { type: 'hidden', name: key, value: params[ key ] } ) );
                          }
                      Severity: Major
                      Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js and 1 other location - About 1 hr to fix
                      modules/ve-mw-collab/ve.ui.MWExportWikitextDialog.js on lines 194..196

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

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

                      ve.ui.MWMediaDialog.prototype.getSetupProcess = function ( data ) {
                          return ve.ui.MWMediaDialog.super.prototype.getSetupProcess.call( this, data )
                              .next( () => {
                                  const isReadOnly = this.isReadOnly();
                      
                      
                      Severity: Minor
                      Found in modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language