wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 436 of 912 total issues

Function parseMetadata has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

ve.init.mw.ArticleTarget.prototype.parseMetadata = function ( response ) {
    const data = response ? ( response.visualeditor || response.visualeditoredit ) : null;

    if ( !data ) {
        this.loadFail( 've-api', { errors: [ {
Severity: Major
Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 2 hrs to fix

    Function VeInitMwArticleTarget has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    ve.init.mw.ArticleTarget = function VeInitMwArticleTarget( config ) {
        config = config || {};
        config.toolbarConfig = ve.extendObject( {
            shadow: true,
            actions: true,
    Severity: Major
    Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 2 hrs to fix

      Function queryCategoryStatus has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ve.ui.MWCategoryWidget.prototype.queryCategoryStatus = function ( categoryNames ) {
          // Get rid of any we already know the hidden status of, or have an entry
          // if normalizedTitles (i.e. have been fetched before)
          const categoryNamesToQuery = categoryNames.filter( ( name ) => {
              if ( this.normalizedTitles[ name ] ) {
      Severity: Major
      Found in modules/ve-mw/ui/widgets/ve.ui.MWCategoryWidget.js - About 2 hrs to fix

        Function create has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        ve.ui.MWWikitextDataTransferHandlerFactory.prototype.create = function () {
            // Parent method
            const handler = ve.ui.MWWikitextDataTransferHandlerFactory.super.prototype.create.apply( this, arguments ),
                resolve = handler.resolve.bind( handler );
        
        
        Severity: Minor
        Found in modules/ve-mw/ui/ve.ui.MWWikitextDataTransferHandlerFactory.js - About 2 hrs 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 build has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        ve.ui.MWTocWidget.prototype.build = function () {
            const $newTocList = $( '<ul>' ),
                nodes = this.doc.getNodesByType( 'mwHeading', true ),
                surfaceView = this.surface.getView(),
                documentView = surfaceView.getDocument(),
        Severity: Minor
        Found in modules/ve-mw/ui/widgets/ve.ui.MWTocWidget.js - About 2 hrs 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 addExactMatch has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        ve.ui.MWTemplateTitleInputWidget.prototype.addExactMatch = function ( response ) {
            const query = this.getQueryValue(),
                title = mw.Title.newFromText( query, this.namespace );
            // No point in trying anything when the title is invalid
            if ( !title ) {
        Severity: Minor
        Found in modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js - About 2 hrs 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 save has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ve.init.mw.ArticleTarget.prototype.save = function ( doc, options ) {
            // Prevent duplicate requests
            if ( this.saving ) {
                return this.saving;
            }
        Severity: Major
        Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 2 hrs to fix

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

          ve.ce.MWBlockImageNode.prototype.onAttributeChange = function ( key, from, to ) {
              // Mixin method
              ve.ce.MWImageNode.prototype.onAttributeChange.apply( this, arguments );
          
              if ( key === 'height' || key === 'width' ) {
          Severity: Major
          Found in modules/ve-mw/ce/nodes/ve.ce.MWBlockImageNode.js - About 2 hrs to fix

            Function generateBody has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            ve.ui.MWInternalLinkContextItem.static.generateBody = function ( linkCache, model, htmlDoc, context ) {
                const lookupTitle = model.getAttribute( 'lookupTitle' ),
                    normalizedTitle = model.getAttribute( 'normalizedTitle' ),
                    href = model.getHref(),
                    title = mw.Title.newFromText( mw.libs.ve.normalizeParsoidResourceName( href ) ),
            Severity: Minor
            Found in modules/ve-mw/ui/contextitems/ve.ui.MWInternalLinkContextItem.js - About 2 hrs to fix

              Function createCheckboxFields has 49 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      createCheckboxFields: function ( checkboxesDef, widgetConfig ) {
                          const checkboxFields = [],
                              checkboxesByName = {};
              
                          if ( checkboxesDef ) {
              Severity: Minor
              Found in modules/ve-mw/preinit/ve.init.mw.ArticleTargetLoader.js - About 1 hr to fix

                Function requestPageData has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        requestPageData: function ( mode, pageName, options ) {
                            options = options || {};
                            const apiRequest = mode === 'source' ?
                                this.requestWikitext.bind( this, pageName, options ) :
                                this.requestParsoidData.bind( this, pageName, options );
                Severity: Minor
                Found in modules/ve-mw/preinit/ve.init.mw.ArticleTargetLoader.js - About 1 hr to fix

                  Function getTarget has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function getTarget( mode, section ) {
                          if ( !targetPromise ) {
                              // The TargetLoader module is loaded in the bottom queue, so it should have been
                              // requested already but it might not have finished loading yet
                              targetPromise = mw.loader.using( 'ext.visualEditor.targetLoader' )
                  Severity: Minor
                  Found in modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js - About 1 hr to fix

                    Function confirmSelectedImage has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    ve.ui.MWMediaDialog.prototype.confirmSelectedImage = function () {
                        const obj = {},
                            info = this.selectedImageInfo;
                    
                        if ( info ) {
                    Severity: Minor
                    Found in modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js - About 1 hr to fix

                      Function restorePage has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      ve.init.mw.DesktopArticleTarget.prototype.restorePage = function () {
                          // Restore any previous redirectMsg/redirectsub
                          this.setRealRedirectInterface();
                          if ( this.$originalCategories ) {
                              $( '#catlinks' ).replaceWith( this.$originalCategories );
                      Severity: Minor
                      Found in modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js - About 1 hr to fix

                        Function VeUiMWCategoriesPage has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        ve.ui.MWCategoriesPage = function VeUiMWCategoriesPage( name, config ) {
                            // Configuration initialization
                            config = config || {};
                        
                            // Parent constructor
                        Severity: Minor
                        Found in modules/ve-mw/ui/pages/ve.ui.MWCategoriesPage.js - About 1 hr to fix

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

                          ve.ui.MWCategoryWidget.prototype.addItems = function ( items, index ) {
                              const categoryItems = [],
                                  // eslint-disable-next-line no-jquery/no-map-util
                                  categoryNames = $.map( items, ( item ) => item.name );
                          
                          
                          Severity: Minor
                          Found in modules/ve-mw/ui/widgets/ve.ui.MWCategoryWidget.js - About 1 hr to fix

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

                            mw.libs.ve.getTargetDataFromHref = function ( href, doc ) {
                                function regexEscape( str ) {
                                    return str.replace( /([.?*+^$[\]\\(){}|-])/g, '\\$1' );
                                }
                            
                            
                            Severity: Minor
                            Found in modules/ve-mw/preinit/ve.utils.parsoid.js - About 1 hr to fix

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

                              ve.ui.MWTemplateDialog.prototype.onReplacePart = function ( removed, added ) {
                                  const removePages = [];
                              
                                  if ( removed ) {
                                      // Remove parameter pages of removed templates
                              Severity: Minor
                              Found in modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js - About 1 hr to fix

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

                                    ve.dm.MWTransclusionModel.prototype.insertTransclusionNode = function ( surfaceFragment, forceType ) {
                                        const deferred = ve.createDeferred(),
                                            baseNodeClass = ve.dm.MWTransclusionNode;
                                
                                        const insertNode = ( isInline, generatedContents ) => {
                                Severity: Minor
                                Found in modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js - About 1 hr to fix

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

                                  ve.ui.MWTemplatePlaceholderPage = function VeUiMWTemplatePlaceholderPage( placeholder, name, config ) {
                                      // Configuration initialization
                                      config = ve.extendObject( {
                                          scrollable: false
                                      }, config );
                                  Severity: Minor
                                  Found in modules/ve-mw/ui/pages/ve.ui.MWTemplatePlaceholderPage.js - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language