wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 436 of 912 total issues

Function toggleWrapSelection has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

ve.ui.MWWikitextAction.prototype.toggleWrapSelection = function ( before, after, placeholder, expandOffsetsCallback, unwrapOffsetsCallback ) {
    const originalFragment = this.surface.getModel().getFragment( null, false, true /* excludeInsertions */ );

    let fragment = originalFragment;
    let textBefore, textAfter;
Severity: Minor
Found in modules/ve-mw/ui/actions/ve.ui.MWWikitextAction.js - About 1 hr to fix

    Function processChangeQueue has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        ve.dm.MWTransclusionModel.prototype.processChangeQueue = function () {
            const templateNamespaceId = mw.config.get( 'wgNamespaceIds' ).template,
                titles = [];
    
            if ( !this.changeQueue.length ) {
    Severity: Minor
    Found in modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js - About 1 hr to fix

      Function createImageNode has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ve.dm.MWImageModel.static.createImageNode = function ( attributes, imageType ) {
          const defaultThumbSize = mw.config.get( 'wgVisualEditorConfig' )
              .thumbLimits[ mw.user.options.get( 'thumbsize' ) ];
      
          const attrs = ve.extendObject( {
      Severity: Minor
      Found in modules/ve-mw/dm/models/ve.dm.MWImageModel.js - About 1 hr to fix

        Function showPreview has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ve.ui.MWSaveDialog.prototype.showPreview = function ( response ) {
            if ( response instanceof $ ) {
                this.$previewViewer.empty().append(
                    // eslint-disable-next-line no-jquery/no-append-html
                    $( '<em>' ).append( response )
        Severity: Minor
        Found in modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js - About 1 hr to fix

          Function getValidationErrors has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          ve.ui.MWAddParameterPage.prototype.getValidationErrors = function ( name ) {
              if ( !name ) {
                  return [];
              }
          
          
          Severity: Minor
          Found in modules/ve-mw/ui/pages/ve.ui.MWAddParameterPage.js - About 1 hr to fix

            Function load has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                ve.dm.MWTransclusionModel.prototype.load = function ( data ) {
                    const promises = [];
            
                    // Convert single part format to multi-part format
                    // Parsoid doesn't use this format any more, but we accept it for backwards compatibility
            Severity: Minor
            Found in modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.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 addPartWidget has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              ve.ui.MWTransclusionOutlineWidget.prototype.addPartWidget = function ( part, newPosition, removed ) {
                  const keys = Object.keys( this.partWidgets ),
                      onlyPart = keys.length === 1 && this.partWidgets[ keys[ 0 ] ];
                  if ( onlyPart instanceof ve.ui.MWTransclusionOutlineTemplateWidget ) {
                      // To recalculate the height of the sticky header when we enter multi-part mode
              Severity: Minor
              Found in modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineWidget.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 toDataElement has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              ve.dm.MWExternalLinkAnnotation.static.toDataElement = function ( domElements, converter ) {
                  const domElement = domElements[ 0 ],
                      type = domElement.getAttribute( 'rel' ) || domElement.getAttribute( 'typeof' ) || domElement.getAttribute( 'property' ) || '',
                      types = type.trim().split( /\s+/ );
              
              
              Severity: Minor
              Found in modules/ve-mw/dm/annotations/ve.dm.MWExternalLinkAnnotation.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 resetDefaultDimensions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              ve.dm.MWImageModel.prototype.resetDefaultDimensions = function () {
                  const originalDimensions = this.scalable.getOriginalDimensions();
              
                  if ( !ve.isEmptyObject( originalDimensions ) ) {
                      if ( this.getType() === 'thumb' || this.getType() === 'frameless' ) {
              Severity: Minor
              Found in modules/ve-mw/dm/models/ve.dm.MWImageModel.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 describeChanges has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              ve.dm.MWExtensionNode.static.describeChanges = function ( attributeChanges, attributes, element ) {
                  const descriptions = [],
                      fromBody = attributeChanges.mw.from.body,
                      toBody = attributeChanges.mw.to.body;
              
              
              Severity: Minor
              Found in modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.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 setType has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              ve.dm.MWImageModel.prototype.setType = function ( type ) {
                  const isDefaultAligned = this.isDefaultAligned( this.imageCurrentType );
              
                  this.type = type;
              
              
              Severity: Minor
              Found in modules/ve-mw/dm/models/ve.dm.MWImageModel.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 matchFunction has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              ve.ui.MWWikitextStringTransferHandler.static.matchFunction = function ( item ) {
                  const text = item.getAsString(),
                      registry = ve.ui.mwWikitextTransferRegistry;
              
                  // If the mime type is explicitly wikitext (ie, not plain text),

              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 onAttributeChange has a Cognitive Complexity of 9 (exceeds 5 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: Minor
              Found in modules/ve-mw/ce/nodes/ve.ce.MWBlockImageNode.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 onUpdate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              ve.ce.MWGalleryNode.prototype.onUpdate = function () {
                  const mwAttrs = this.model.getAttribute( 'mw' ).attrs;
                  const defaults = mw.config.get( 'wgVisualEditorConfig' ).galleryOptions;
                  const mode = mwAttrs.mode || defaults.mode;
              
              
              Severity: Minor
              Found in modules/ve-mw/ce/nodes/ve.ce.MWGalleryNode.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

              Method onVisualEditorApiVisualEditorEditPostSave has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      ProperPageIdentity $page,
                      UserIdentity $user,
                      string $wikitext,
                      array $params,
                      array $pluginData,
              Severity: Major
              Found in includes/VisualEditorHookRunner.php - About 50 mins to fix

                Method onVisualEditorApiVisualEditorEditPostSave has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        ProperPageIdentity $page,
                        UserIdentity $user,
                        string $wikitext,
                        array $params,
                        array $pluginData,
                Severity: Major
                Found in includes/VisualEditorApiVisualEditorEditPostSaveHook.php - About 50 mins to fix

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

                  ve.ui.MWDefinedTransclusionContextItem.prototype.getCanonicalParam = function ( name ) {
                      const params = this.tool.params || {};
                  
                      if ( Object.prototype.hasOwnProperty.call( params, name ) ) {
                          const aliases = Array.isArray( params[ name ] ) ? params[ name ] : [ params[ name ] ];
                  Severity: Minor
                  Found in modules/ve-mw/ui/contextitems/ve.ui.MWDefinedTransclusionContextItem.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

                  Avoid deeply nested control flow statements.
                  Open

                                      if ( reselect ) {
                                          this.bookletLayout.focusPart( reselect );
                                      }
                  Severity: Major
                  Found in modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js - About 45 mins to fix

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

                    ve.ui.MWExtensionDialog.prototype.getActionProcess = function ( action ) {
                        if ( action === '' ) {
                            if ( this.hasMeaningfulEdits() ) {
                                // eslint-disable-next-line arrow-body-style
                                return new OO.ui.Process( () => {
                    Severity: Minor
                    Found in modules/ve-mw/ui/dialogs/ve.ui.MWExtensionDialog.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

                    Severity
                    Category
                    Status
                    Source
                    Language