wikimedia/mediawiki-extensions-VisualEditor

View on GitHub
modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js

Summary

Maintainability
F
1 wk
Test Coverage

File ve.init.mw.ArticleTarget.js has 1483 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 * VisualEditor MediaWiki Initialization ArticleTarget class.
 *
 * @copyright See AUTHORS.txt
 * @license The MIT License (MIT); see LICENSE.txt
Severity: Major
Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 3 days to fix

    Function saveFail has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    ve.init.mw.ArticleTarget.prototype.saveFail = function ( doc, saveData, code, data ) {
        this.pageDeletedWarning = false;
    
        let handled = false;
        // Handle empty response
    Severity: Minor
    Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 3 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 getVisualDiffGeneratorPromise has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    ve.init.mw.ArticleTarget.prototype.getVisualDiffGeneratorPromise = function () {
        return mw.loader.using( 'ext.visualEditor.diffLoader' ).then( () => {
            const mode = this.getSurface().getMode();
    
            if ( !this.originalDmDocPromise ) {
    Severity: Minor
    Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.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 saveComplete has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    ve.init.mw.ArticleTarget.prototype.saveComplete = function ( data ) {
        this.editSummaryValue = null;
        this.initialEditSummary = null;
    
        this.saveDeferred.resolve();
    Severity: Major
    Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 2 hrs to fix

      Function renderCategories has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ve.init.mw.ArticleTarget.prototype.renderCategories = function ( categoryItems ) {
          const promises = [],
              categories = { hidden: {}, normal: {} };
          categoryItems.forEach( ( categoryItem, index ) => {
              const attributes = ve.copy( ve.getProp( categoryItem, 'element', 'attributes' ) );
      Severity: Major
      Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 2 hrs to fix

        Function showSaveDialog has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ve.init.mw.ArticleTarget.prototype.showSaveDialog = function ( action, checkboxName ) {
            let firstLoad = false;
        
            if ( !this.isSaveable() || this.saveDialogIsOpening ) {
                return;
        Severity: Major
        Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 2 hrs to fix

          Function restoreEditSection has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          ve.init.mw.ArticleTarget.prototype.restoreEditSection = function () {
              const section = this.section !== null ? this.section : this.visibleSection;
              const surface = this.getSurface();
              const mode = surface.getMode();
          
          
          Severity: Minor
          Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.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 a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

          ve.init.mw.ArticleTarget.prototype.save = function ( doc, options ) {
              // Prevent duplicate requests
              if ( this.saving ) {
                  return this.saving;
              }
          Severity: Minor
          Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.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 saveFail has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          ve.init.mw.ArticleTarget.prototype.saveFail = function ( doc, saveData, code, data ) {
              this.pageDeletedWarning = false;
          
              let handled = false;
              // Handle empty response
          Severity: Major
          Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 2 hrs to fix

            Function restoreEditSection has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            ve.init.mw.ArticleTarget.prototype.restoreEditSection = function () {
                const section = this.section !== null ? this.section : this.visibleSection;
                const surface = this.getSurface();
                const mode = surface.getMode();
            
            
            Severity: Major
            Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 2 hrs to fix

              Function prepareCacheKey has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              ve.init.mw.ArticleTarget.prototype.prepareCacheKey = function ( doc ) {
                  const start = ve.now();
              
                  if ( this.getSurface().getMode() === 'source' ) {
                      return;
              Severity: Major
              Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 2 hrs to fix

                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 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 updateRedirectInterface has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                      ve.init.mw.ArticleTarget.prototype.updateRedirectInterface = function ( $sub, $msg ) {
                          // For the subtitle, replace the real one with ours.
                          // This is more complicated than it should be because we have to fiddle with the <br>.
                          const $currentSub = $( '#redirectsub' );
                          if ( $currentSub.length ) {
                      Severity: Minor
                      Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.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 getVisualDiffGeneratorPromise has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      ve.init.mw.ArticleTarget.prototype.getVisualDiffGeneratorPromise = function () {
                          return mw.loader.using( 'ext.visualEditor.diffLoader' ).then( () => {
                              const mode = this.getSurface().getMode();
                      
                              if ( !this.originalDmDocPromise ) {
                      Severity: Minor
                      Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 1 hr to fix

                        Function loadSuccess has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        ve.init.mw.ArticleTarget.prototype.loadSuccess = function ( response ) {
                            const data = response ? ( response.visualeditor || response.visualeditoredit ) : null;
                        
                            if ( !data || typeof data.content !== 'string' ) {
                                this.loadFail( 've-api', { errors: [ {
                        Severity: Minor
                        Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 1 hr to fix

                          Function getSaveFields has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                          ve.init.mw.ArticleTarget.prototype.getSaveFields = function () {
                              const fields = {};
                          
                              if ( this.section === 'new' ) {
                                  // MediaWiki action=edit UI doesn't have separate parameters for edit summary and new section
                          Severity: Minor
                          Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.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 parseMetadata has a Cognitive Complexity of 12 (exceeds 5 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: Minor
                          Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.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 loadSuccess has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                          ve.init.mw.ArticleTarget.prototype.loadSuccess = function ( response ) {
                              const data = response ? ( response.visualeditor || response.visualeditoredit ) : null;
                          
                              if ( !data || typeof data.content !== 'string' ) {
                                  this.loadFail( 've-api', { errors: [ {
                          Severity: Minor
                          Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.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 onSaveDialogPreview has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          ve.init.mw.ArticleTarget.prototype.onSaveDialogPreview = function () {
                              const api = this.getContentApi();
                          
                              if ( !this.saveDialog.$previewViewer.children().length ) {
                                  this.emit( 'savePreview' );
                          Severity: Minor
                          Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 1 hr to fix

                            Function surfaceReady has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            ve.init.mw.ArticleTarget.prototype.surfaceReady = function () {
                                const accessKeyPrefix = $.fn.updateTooltipAccessKeys.getAccessKeyPrefix().replace( /-/g, '+' ),
                                    accessKeyModifiers = new ve.ui.Trigger( accessKeyPrefix + '-' ).modifiers,
                                    surfaceModel = this.getSurface().getModel();
                            
                            
                            Severity: Minor
                            Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.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 updateRedirectInterface has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                ve.init.mw.ArticleTarget.prototype.updateRedirectInterface = function ( $sub, $msg ) {
                                    // For the subtitle, replace the real one with ours.
                                    // This is more complicated than it should be because we have to fiddle with the <br>.
                                    const $currentSub = $( '#redirectsub' );
                                    if ( $currentSub.length ) {
                                Severity: Minor
                                Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 1 hr to fix

                                  Function surfaceReady has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  ve.init.mw.ArticleTarget.prototype.surfaceReady = function () {
                                      const accessKeyPrefix = $.fn.updateTooltipAccessKeys.getAccessKeyPrefix().replace( /-/g, '+' ),
                                          accessKeyModifiers = new ve.ui.Trigger( accessKeyPrefix + '-' ).modifiers,
                                          surfaceModel = this.getSurface().getModel();
                                  
                                  
                                  Severity: Minor
                                  Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.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 tryWithPreparedCacheKey has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  ve.init.mw.ArticleTarget.prototype.tryWithPreparedCacheKey = function ( doc, extraData, eventName ) {
                                      if ( this.getSurface().getMode() === 'source' ) {
                                          const data = ve.copy( extraData );
                                  
                                          // TODO: This should happen in #getSaveOptions, check if moving it there breaks anything
                                  Severity: Minor
                                  Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 1 hr to fix

                                    Function teardown has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                    ve.init.mw.ArticleTarget.prototype.teardown = function () {
                                        if ( !this.teardownPromise ) {
                                            const surface = this.getSurface();
                                    
                                            // Restore access keys
                                    Severity: Minor
                                    Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.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 submit has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    ve.init.mw.ArticleTarget.prototype.submit = function ( wikitext, fields ) {
                                        // Prevent duplicate requests
                                        if ( this.submitting ) {
                                            return false;
                                        }
                                    Severity: Minor
                                    Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 1 hr to fix

                                      Function getSaveButtonLabel has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                      ve.init.mw.ArticleTarget.prototype.getSaveButtonLabel = function ( startProcess, forceShort ) {
                                          const suffix = startProcess ? '-start' : '';
                                      
                                          if ( forceShort || OO.ui.isMobile() ) {
                                              // The following messages can be used here:
                                      Severity: Minor
                                      Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 55 mins 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 replacePageContent has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                          html, categoriesHtml, displayTitle, lastModified, contentSub, sections
                                      Severity: Minor
                                      Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 45 mins to fix

                                        Function saveComplete has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                        ve.init.mw.ArticleTarget.prototype.saveComplete = function ( data ) {
                                            this.editSummaryValue = null;
                                            this.initialEditSummary = null;
                                        
                                            this.saveDeferred.resolve();
                                        Severity: Minor
                                        Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 45 mins 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 onSaveDialogPreview has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                        ve.init.mw.ArticleTarget.prototype.onSaveDialogPreview = function () {
                                            const api = this.getContentApi();
                                        
                                            if ( !this.saveDialog.$previewViewer.children().length ) {
                                                this.emit( 'savePreview' );
                                        Severity: Minor
                                        Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 35 mins 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 VeInitMwArticleTarget has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                        ve.init.mw.ArticleTarget = function VeInitMwArticleTarget( config ) {
                                            config = config || {};
                                            config.toolbarConfig = ve.extendObject( {
                                                shadow: true,
                                                actions: true,
                                        Severity: Minor
                                        Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 35 mins 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 prepareCacheKey has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                        ve.init.mw.ArticleTarget.prototype.prepareCacheKey = function ( doc ) {
                                            const start = ve.now();
                                        
                                            if ( this.getSurface().getMode() === 'source' ) {
                                                return;
                                        Severity: Minor
                                        Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 35 mins 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 setDefaultMode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                        ve.init.mw.ArticleTarget.prototype.setDefaultMode = function () {
                                            const oldDefaultMode = this.defaultMode;
                                            // Parent method
                                            ve.init.mw.ArticleTarget.super.prototype.setDefaultMode.apply( this, arguments );
                                        
                                        
                                        Severity: Minor
                                        Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 25 mins 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 switchToWikitextEditor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                        ve.init.mw.ArticleTarget.prototype.switchToWikitextEditor = function ( modified ) {
                                            // When switching with changes we always pass the full page as changes in visual section mode
                                            // can still affect the whole document (e.g. removing a reference)
                                            if ( modified ) {
                                                this.section = null;
                                        Severity: Minor
                                        Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 25 mins 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 onSaveDialogReview has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                        ve.init.mw.ArticleTarget.prototype.onSaveDialogReview = function () {
                                            if ( !this.saveDialog.hasDiff ) {
                                                this.emit( 'saveReview' );
                                                this.saveDialog.pushPending();
                                                // Acquire a temporary user username before diffing, so that signatures and
                                        Severity: Minor
                                        Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 25 mins 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 getSectionHashFromPage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                        ve.init.mw.ArticleTarget.prototype.getSectionHashFromPage = function () {
                                            // Assume there are section edit links, as the user just did a section edit. This also means
                                            // that the section numbers line up correctly, as not every H_ tag is a numbered section.
                                            const $sections = this.$editableContent.find( '.mw-editsection' );
                                        
                                        
                                        Severity: Minor
                                        Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 25 mins 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

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

                                        ve.init.mw.ArticleTarget.prototype.getSurfaceClasses = function () {
                                            const classes = ve.init.mw.ArticleTarget.super.prototype.getSurfaceClasses.call( this );
                                            return [ ...classes, 'mw-body-content' ];
                                        };
                                        Severity: Major
                                        Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js and 1 other location - About 2 hrs to fix
                                        modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js on lines 264..267

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

                                        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

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

                                        ve.init.mw.ArticleTarget.prototype.saveErrorUnknown = function ( data ) {
                                            this.showSaveError( this.extractErrorMessages( data ) );
                                        };
                                        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/init/targets/ve.init.mw.ArticleTarget.js on lines 870..872

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

                                        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.init.mw.ArticleTarget.prototype.saveErrorHookAborted = function ( data ) {
                                            this.showSaveError( this.extractErrorMessages( data ) );
                                        };
                                        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/init/targets/ve.init.mw.ArticleTarget.js on lines 898..900

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

                                        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

                                                this.wikitextDiffPromise = this.tryWithPreparedCacheKey( doc, {
                                                    paction: 'diff',
                                                    page: this.getPageName(),
                                                    oldid: this.revid,
                                                    etag: this.etag
                                        Severity: Minor
                                        Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js and 1 other location - About 50 mins to fix
                                        modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js on lines 1713..1719

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

                                        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

                                            const promise = this.serializing = this.tryWithPreparedCacheKey( doc, {
                                                paction: 'serialize',
                                                page: this.getPageName(),
                                                oldid: this.revid,
                                                etag: this.etag
                                        Severity: Minor
                                        Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js and 1 other location - About 50 mins to fix
                                        modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js on lines 1626..1636

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

                                        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

                                            $( '[accesskey=' + key + ']' ).each( ( i, el ) => {
                                                const $el = $( el );
                                        
                                                $el
                                                    .attr( 'data-old-accesskey', $el.attr( 'accesskey' ) )
                                        Severity: Minor
                                        Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js and 1 other location - About 40 mins to fix
                                        modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js on lines 574..580

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

                                        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

                                            $( '[data-old-accesskey]' ).each( ( i, el ) => {
                                                const $el = $( el );
                                        
                                                $el
                                                    .attr( 'accesskey', $el.attr( 'data-old-accesskey' ) )
                                        Severity: Minor
                                        Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js and 1 other location - About 40 mins to fix
                                        modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js on lines 561..567

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

                                        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

                                                this.loadFail( 've-api', { errors: [ {
                                                    code: 've-api',
                                                    html: mw.message( 'api-clientside-error-invalidresponse' ).parse()
                                                } ] } );
                                        Severity: Minor
                                        Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js and 1 other location - About 35 mins to fix
                                        modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js on lines 304..307

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

                                        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

                                                this.loadFail( 've-api', { errors: [ {
                                                    code: 've-api',
                                                    html: mw.message( 'api-clientside-error-invalidresponse' ).parse()
                                                } ] } );
                                        Severity: Minor
                                        Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js and 1 other location - About 35 mins to fix
                                        modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js on lines 363..366

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

                                        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

                                        There are no issues that match your filters.

                                        Category
                                        Status