wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 436 of 912 total issues

Function onRequestImagesSuccess has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

ve.ui.MWGalleryDialog.prototype.onRequestImagesSuccess = function ( response ) {
    const thumbUrls = {},
        items = [],
        config = { isMobile: this.isMobile, draggable: !this.isReadOnly() };

Severity: Minor
Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js - About 1 hr to fix

    Function getHtml has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            getHtml: function ( newDoc, oldDoc ) {
                function copyAttributes( from, to ) {
                    Array.prototype.forEach.call( from.attributes, ( attr ) => {
                        to.setAttribute( attr.name, attr.value );
                    } );
    Severity: Minor
    Found in modules/ve-mw/preinit/ve.init.mw.ArticleTargetSaver.js - About 1 hr to fix

      Method parseWikitext has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function parseWikitext( $newRevId, array $params ) {
              $apiParams = [
                  'action' => 'parse',
                  'oldid' => $newRevId,
                  'prop' => 'text|revid|categorieshtml|sections|displaytitle|subtitle|modules|jsconfigvars',
      Severity: Minor
      Found in includes/ApiVisualEditorEdit.php - About 1 hr to fix

        Function describeChanges has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ve.dm.MWTransclusionNode.static.describeChanges = function ( attributeChanges ) {
            const descriptions = [ ve.msg( 'visualeditor-changedesc-mwtransclusion' ) ];
        
            // This method assumes that the behavior of isDiffComparable above remains
            // the same, so it doesn't have to consider whether the actual template
        Severity: Minor
        Found in modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js - About 1 hr to fix

          Function generateContents has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          ve.ce.MWSignatureNode.prototype.generateContents = function () {
              const doc = this.getModel().getDocument();
              let abortable, aborted;
              const abortedPromise = ve.createDeferred().reject( 'http',
                  { textStatus: 'abort', exception: 'abort' } ).promise();
          Severity: Minor
          Found in modules/ve-mw/ce/nodes/ve.ce.MWSignatureNode.js - About 1 hr to fix

            Function initialize has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            ve.ui.EditCheckInspector.prototype.initialize = function () {
                // Parent method
                ve.ui.EditCheckInspector.super.prototype.initialize.call( this );
            
                // Survey panel
            Severity: Minor
            Found in editcheck/modules/EditCheckInspector.js - About 1 hr to fix

              Function act has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              mw.editcheck.AddReferenceEditCheck.prototype.act = function ( choice, action, contextItem ) {
                  // The complex citoid workflow means that we can't just count on a single "windowAction" here...
                  const windowAction = ve.ui.actionFactory.create( 'window', contextItem.context.getSurface(), 'check' );
                  switch ( choice ) {
                      case 'accept':
              Severity: Minor
              Found in editcheck/modules/AddReferenceEditCheck.js - About 1 hr to fix

                Function isSaveable has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                ve.ui.MWGalleryDialog.prototype.isSaveable = function () {
                    // Check attributes
                    if ( this.originalMwDataNormalized ) {
                        const mwDataCopy = ve.copy( this.selectedNode.getAttribute( 'mw' ) );
                        this.updateMwData( mwDataCopy );
                Severity: Minor
                Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js - About 1 hr to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function wrapText has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                ve.dm.MWWikitextSurfaceFragment.prototype.wrapText = function ( before, after, placeholder, forceWrap ) {
                    placeholder = OO.ui.resolveMsg( placeholder );
                
                    function unwrap( fragment ) {
                        const text = fragment.getText();
                Severity: Minor
                Found in modules/ve-mw/dm/ve.dm.MWWikitextSurfaceFragment.js - About 1 hr to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

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

                        ApiMain $main,
                        string $name,
                        RevisionLookup $revisionLookup,
                        TempUserCreator $tempUserCreator,
                        UserFactory $userFactory,
                Severity: Major
                Found in includes/ApiVisualEditor.php - About 1 hr to fix

                  Function syncScalableToType has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                  ve.dm.MWImageNode.static.syncScalableToType = function ( type, mediaType, scalable ) {
                      const defaultThumbSize = mw.config.get( 'wgVisualEditorConfig' )
                          .thumbLimits[ mw.user.options.get( 'thumbsize' ) ];
                  
                      const originalDimensions = scalable.getOriginalDimensions();
                  Severity: Minor
                  Found in modules/ve-mw/dm/nodes/ve.dm.MWImageNode.js - About 1 hr to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Function fetchSpecialCharList has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  ve.init.mw.Platform.prototype.fetchSpecialCharList = function () {
                      return mw.loader.using( 'mediawiki.language.specialCharacters' ).then( () => {
                          const specialCharacterGroups = require( 'mediawiki.language.specialCharacters' ),
                              characters = {},
                              otherGroupName = mw.msg( 'visualeditor-special-characters-group-other' ),
                  Severity: Minor
                  Found in modules/ve-mw/init/ve.init.mw.Platform.js - About 1 hr to fix

                    Function resolveChangeQueue has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        ve.dm.MWTransclusionModel.prototype.resolveChangeQueue = function ( queue ) {
                            const resolveQueue = [];
                    
                            for ( let i = 0; i < queue.length; i++ ) {
                                const item = queue[ i ];
                    Severity: Minor
                    Found in modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js - About 1 hr to fix

                      Function initialize has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      ve.ui.MWExportWikitextDialog.prototype.initialize = function () {
                          // Parent method
                          ve.ui.MWExportWikitextDialog.super.prototype.initialize.call( this );
                      
                          this.titleInput = new mw.widgets.TitleInputWidget( {
                      Severity: Minor
                      Found in modules/ve-mw-collab/ve.ui.MWExportWikitextDialog.js - About 1 hr to fix

                        Function getTeardownProcess has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        ve.ui.MWLinkNodeInspector.prototype.getTeardownProcess = function ( data ) {
                            data = data || {};
                            return ve.ui.MWLinkNodeInspector.super.prototype.getTeardownProcess.call( this, data )
                                .first( () => {
                                    let value = this.targetInput.getValue();
                        Severity: Minor
                        Found in modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js - About 1 hr to fix

                          Function VeInitMwDesktopArticleTarget has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          ve.init.mw.DesktopArticleTarget = function VeInitMwDesktopArticleTarget( config ) {
                              // Parent constructor
                              ve.init.mw.DesktopArticleTarget.super.call( this, config );
                          
                              // Parent constructor bound key event handlers, but we don't want them bound until
                          Severity: Minor
                          Found in modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js - About 1 hr to fix

                            Function initialize has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            ve.ui.MWAddParameterPage.prototype.initialize = function () {
                                this.template
                                    .connect( this, {
                                        // There is a "change" event, but it triggers way to often even for content changes
                                        add: 'onTemplateParametersChanged',
                            Severity: Minor
                            Found in modules/ve-mw/ui/pages/ve.ui.MWAddParameterPage.js - About 1 hr to fix

                              Function setDiffAndReview has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              ve.ui.MWSaveDialog.prototype.setDiffAndReview = function ( wikitextDiffPromise, visualDiffGeneratorPromise, baseDoc ) {
                                  this.clearDiff();
                              
                                  function createDiffElement( visualDiff ) {
                                      const diffElement = new ve.ui.DiffElement( visualDiff );
                              Severity: Minor
                              Found in modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js - About 1 hr to fix

                                Function VeDmMWImageModel has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                ve.dm.MWImageModel = function VeDmMWImageModel( parentDoc, config ) {
                                    config = config || {};
                                
                                    // Mixin constructors
                                    OO.EventEmitter.call( this );
                                Severity: Minor
                                Found in modules/ve-mw/dm/models/ve.dm.MWImageModel.js - About 1 hr to fix

                                  Function initAutosave has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  ve.init.mw.Target.prototype.initAutosave = function ( config ) {
                                      // Old function signature
                                      // TODO: Remove after fixed downstream
                                      if ( typeof config === 'boolean' ) {
                                          config = { suppressNotification: config };
                                  Severity: Minor
                                  Found in modules/ve-mw/init/targets/ve.init.mw.Target.js - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language