wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 912 of 912 total issues

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

ve.init.mw.DesktopArticleTarget.prototype.updateHistoryState = function () {
    const veaction = this.getDefaultMode() === 'visual' ? 'edit' : 'editsource',
        section = this.section;

    // Push veaction=edit(source) url in history (if not already present).
Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.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 toDomElements has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

ve.dm.MWNowikiAnnotation.static.toDomElements = function ( dataElement, doc, converter, childDomElements ) {
    const originalDomElements = converter.getStore().value( dataElement.originalDomElementsHash ),
        originalChildren = originalDomElements && originalDomElements[ 0 ] && originalDomElements[ 0 ].childNodes,
        domElement = document.createElement( 'span' );

Severity: Minor
Found in modules/ve-mw/dm/annotations/ve.dm.MWNowikiAnnotation.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 setSelectionByPageName has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWTransclusionOutlineWidget.prototype.setSelectionByPageName = function ( pageName ) {
    const selectedPartId = pageName ? pageName.split( '/', 1 )[ 0 ] : null,
        isParameter = pageName ? pageName.length > selectedPartId.length : false;

    for ( const partId in this.partWidgets ) {
Severity: Minor
Found in modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineWidget.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 initFromMetaList has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWTocWidget.prototype.initFromMetaList = function () {
    const items = this.metaList.getItemsInGroup( 'mwTOC' );
    if ( items.length === 0 ) {
        return;
    }
Severity: Minor
Found in modules/ve-mw/ui/widgets/ve.ui.MWTocWidget.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 VeUiMWParameterPage has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWParameterPage = function VeUiMWParameterPage( parameter, config ) {
    const paramName = parameter.getName();

    // Configuration initialization
    config = ve.extendObject( {
Severity: Minor
Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.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 getTargetDataFromHref has a Cognitive Complexity of 10 (exceeds 5 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

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

ve.ce.MWExtensionNode.prototype.generateContents = function ( config ) {
    const deferred = ve.createDeferred(),
        mwData = ve.copy( this.getModel().getAttribute( 'mw' ) ),
        extsrc = config && config.extsrc !== undefined ? config.extsrc : ( ve.getProp( mwData, 'body', 'extsrc' ) || '' ),
        attrs = config && config.attrs || mwData.attrs,
Severity: Minor
Found in modules/ve-mw/ce/nodes/ve.ce.MWExtensionNode.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 updateHistoryState has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

ve.init.mw.DesktopArticleTarget.prototype.updateHistoryState = function () {
    const veaction = this.getDefaultMode() === 'visual' ? 'edit' : 'editsource',
        section = this.section;

    // Push veaction=edit(source) url in history (if not already present).
Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js - About 1 hr to fix

    Function create has 27 lines of code (exceeds 25 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 1 hr to fix

      Function runDiffTest has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              runDiffTest: function ( oldHtml, newHtml, done ) {
                  const target = ve.init.target,
                      surface = target.surface;
      
                  if ( target.saveDialog ) {
      Severity: Minor
      Found in build/screenshots-client/utils.js - About 1 hr to fix

        Function resetCaption has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ve.ui.MWMediaDialog.prototype.resetCaption = function () {
            const doc = this.getFragment().getDocument();
        
            // Get existing caption. We only do this in setup, because the caption
            // should not reset to original if the image is replaced or edited.
        Severity: Minor
        Found in modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js - About 1 hr to fix

          Function setupHotkeyTriggers has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          ve.ui.MWTransclusionDialog.prototype.setupHotkeyTriggers = function () {
              // Lower-case modifier and key names as specified in {@see ve.ui.Trigger}
              const isMac = ve.getSystemPlatform() === 'mac',
                  meta = isMac ? 'meta+' : 'ctrl+';
              const hotkeys = {
          Severity: Minor
          Found in modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js - About 1 hr to fix

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

            ve.init.mw.DesktopArticleTarget.prototype.surfaceReady = function () {
                if ( !this.activating ) {
                    // Activation was aborted before we got here. Do nothing
                    // TODO are there things we need to clean up?
                    return;
            Severity: Minor
            Found in modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js - About 1 hr to fix

              Function attachImageModel has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              ve.ui.MWMediaDialog.prototype.attachImageModel = function () {
                  if ( this.imageModel ) {
                      this.imageModel.disconnect( this );
                      this.sizeWidget.disconnect( this );
                  }
              Severity: Minor
              Found in modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js - About 1 hr to fix

                Function removePages has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.removePages = function ( pagesNamesToRemove ) {
                    const pagesToRemove = [],
                        isCurrentParameter = this.pages[ this.currentPageName ] instanceof ve.ui.MWParameterPage;
                    let isCurrentPageRemoved = false,
                        prevSelectionCandidate, nextSelectionCandidate;
                Severity: Minor
                Found in modules/ve-mw/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.js - About 1 hr to fix

                  Function selectRange has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  ve.ui.MWAceEditorWidget.prototype.selectRange = function ( from, to ) {
                      this.focus();
                      this.loadingPromise.done( () => {
                          const doc = this.editor.getSession().getDocument(),
                              lines = doc.getAllLines();
                  Severity: Minor
                  Found in modules/ve-mw/ui/widgets/ve.ui.MWAceEditorWidget.js - About 1 hr to fix

                    Function describeChanges has 27 lines of code (exceeds 25 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 1 hr to fix

                      Function initializeFilters has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      ve.ui.MWTransclusionOutlineTemplateWidget.prototype.initializeFilters = function () {
                          this.searchWidget = new OO.ui.SearchInputWidget( {
                              title: ve.msg( 'visualeditor-dialog-transclusion-filter-title', this.templateModel.getSpec().getLabel() ),
                              placeholder: ve.msg( 'visualeditor-dialog-transclusion-filter-placeholder' ),
                              classes: [ 've-ui-mwTransclusionOutlineTemplateWidget-searchWidget' ]

                        Function hasMatchingAncestor has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        ve.dm.MWWikitextSurfaceFragment.prototype.hasMatchingAncestor = function ( type, attributes ) {
                            const nodes = this.getSelectedLeafNodes();
                        
                            let all = !!nodes.length;
                            for ( let i = 0, len = nodes.length; i < len; i++ ) {
                        Severity: Minor
                        Found in modules/ve-mw/dm/ve.dm.MWWikitextSurfaceFragment.js - About 1 hr to fix

                          Function getCategoryWidgetFromName has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          ve.ui.MWCategoryInputWidget.prototype.getCategoryWidgetFromName = function ( name ) {
                              const cachedData = ve.init.platform.linkCache.getCached( mw.Title.newFromText(
                                  name,
                                  mw.config.get( 'wgNamespaceIds' ).category
                              ).getPrefixedText() );
                          Severity: Minor
                          Found in modules/ve-mw/ui/widgets/ve.ui.MWCategoryInputWidget.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language