wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 912 of 912 total issues

Function onDocumentKeyDown has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.onDocumentKeyDown = function ( e ) {
    let item;

    switch ( e.keyCode ) {
        case OO.ui.Keys.HOME:

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

ve.dm.MWLanguageVariantNode.static.getPreviewHtml = function ( variantInfo, opts ) {
    if ( variantInfo.disabled ) {
        return variantInfo.disabled.t;
    } else if ( variantInfo.name ) {
        return ve.init.platform.getLanguageName( variantInfo.name.t.toLowerCase() );
Severity: Minor
Found in modules/ve-mw/dm/nodes/ve.dm.MWLanguageVariantNode.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 getTeardownProcess has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

ve.ui.MWMagicLinkNodeInspector.prototype.getTeardownProcess = function ( data ) {
    data = data || {};
    return ve.ui.MWMagicLinkNodeInspector.super.prototype.getTeardownProcess.call( this, data )
        .first( () => {
            const surfaceView = this.manager.getSurface().getView(),
Severity: Minor
Found in modules/ve-mw/ui/inspectors/ve.ui.MWMagicLinkNodeInspector.js - About 1 hr to fix

    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 VeUiMWCategoryPopupWidget has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ve.ui.MWCategoryPopupWidget = function VeUiMWCategoryPopupWidget( config ) {
          // Configuration initialization
          config = ve.extendObject( { autoClose: true }, config );
      
          // Parent constructor
      Severity: Minor
      Found in modules/ve-mw/ui/widgets/ve.ui.MWCategoryPopupWidget.js - About 1 hr to fix

        Function getSetupProcess has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ve.ui.MWSaveDialog.prototype.getSetupProcess = function ( data ) {
            return ve.ui.MWSaveDialog.super.prototype.getSetupProcess.call( this, data )
                .next( () => {
                    const surfaceMode = ve.init.target.getSurface().getMode();
        
        
        Severity: Minor
        Found in modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js - About 1 hr to fix

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

          ve.dm.MWImageNode.static.describeChanges = function ( attributeChanges, attributes ) {
              const customKeys = [ 'width', 'height', 'defaultSize', 'src', 'href' ],
                  descriptions = [];
          
              function describeSize( width, height ) {
          Severity: Minor
          Found in modules/ve-mw/dm/nodes/ve.dm.MWImageNode.js - About 1 hr to fix

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

                                setTimeout( () => {
                                    done(
                                        seleniumUtils.getBoundingRect( [
                                            surface.$element.find( '.ve-ce-linkAnnotation' )[ 0 ],
                                            surface.context.inspectors.currentWindow.$element[ 0 ]
            Severity: Major
            Found in build/screenshots-client/userGuide.js and 1 other location - About 1 hr to fix
            build/screenshots-client/userGuide.js on lines 30..37

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

            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

                            fragment.changeAttributes( {
                                wikitable: this.wikitableToggle.getValue(),
                                sortable: this.sortableToggle.getValue(),
                                collapsible: this.collapsibleToggle.getValue(),
                                collapsed: this.collapsedToggle.getValue()
            Severity: Major
            Found in modules/ve-mw/ui/dialogs/ve.ui.MWTableDialog.js and 1 other location - About 1 hr to fix
            modules/ve-mw/ui/dialogs/ve.ui.MWTableDialog.js on lines 33..38

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

            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.ui.MWLinkAnnotationInspector.prototype.onInternalLinkSearchResultsChoose = function () {
                ve.track( 'activity.' + this.constructor.static.name, { action: 'search-pages-choose' } );
            };
            modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js on lines 857..861

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

            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

                    setTimeout( () => {
                        done(
                            seleniumUtils.getBoundingRect( [
                                surface.$element.find( '.ve-ce-mwReferenceNode' )[ 0 ],
                                surface.context.inspectors.currentWindow.$element[ 0 ]
            Severity: Major
            Found in build/screenshots-client/userGuide.js and 1 other location - About 1 hr to fix
            build/screenshots-client/userGuide.js on lines 243..250

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

            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

                return ve.extendObject( values, {
                    wikitable: this.wikitableToggle.getValue(),
                    sortable: this.sortableToggle.getValue(),
                    collapsible: this.collapsibleToggle.getValue(),
                    collapsed: this.collapsedToggle.getValue()
            Severity: Major
            Found in modules/ve-mw/ui/dialogs/ve.ui.MWTableDialog.js and 1 other location - About 1 hr to fix
            modules/ve-mw/ui/dialogs/ve.ui.MWTableDialog.js on lines 124..129

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

            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.ui.MWMediaDialog.prototype.onSearchQueryClear = function () {
                ve.track( 'activity.' + this.constructor.static.name, {
                    action: 'search-clear-query'
                } );
            };
            Severity: Major
            Found in modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js and 1 other location - About 1 hr to fix
            modules/ve-mw/ui/inspectors/ve.ui.MWLinkAnnotationInspector.js on lines 192..194

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

            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

                                .append( $( '<tr>' )
                                    // eslint-disable-next-line no-jquery/no-html
                                    .append( $( '<td>' ).html( name ).attr( 'lang', code ) )
                                    .append( $( '<td>' ).text( code ) )
                                    .append( $text )
            modules/ve-mw/ui/contextitems/ve.ui.MWLanguageVariantNodeContextItem.js on lines 143..147

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

            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

                                .append( $( '<tr>' )
                                    // eslint-disable-next-line no-jquery/no-html
                                    .append( $( '<td>' ).html( name ).attr( 'lang', code ) )
                                    .append( $( '<td>' ).text( code ) )
                                    .append( $fromText )
            modules/ve-mw/ui/contextitems/ve.ui.MWLanguageVariantNodeContextItem.js on lines 174..178

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

            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

            Function getActionProcess has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            ve.ui.MWTemplateDialog.prototype.getActionProcess = function ( action ) {
                if ( action === 'done' ) {
                    return new OO.ui.Process( () => {
                        const deferred = ve.createDeferred();
                        this.checkRequiredParameters().done( () => {
            Severity: Minor
            Found in modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js - About 1 hr to fix

              Function onContainerScroll has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              ve.init.mw.MobileArticleTarget.prototype.onContainerScroll = function () {
                  // Editor may not have loaded yet, in which case `this.surface` is undefined
                  const surfaceView = this.surface && this.surface.getView(),
                      isActiveWithKeyboard = surfaceView && surfaceView.isFocused() && !surfaceView.isDeactivated();
              
              
              Severity: Minor
              Found in modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js - About 1 hr to fix

                Method diffWikitext has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function diffWikitext( Title $title, ?int $fromId, $wikitext, $section = null ) {
                        $apiParams = [
                            'action' => 'compare',
                            'prop' => 'diff',
                            // Because we're just providing wikitext, we only care about the main slot
                Severity: Minor
                Found in includes/ApiVisualEditorEdit.php - About 1 hr to fix

                  Function onEditTabClick has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          onEditTabClick: function ( mode, e ) {
                              if ( !init.isUnmodifiedLeftClick( e ) ) {
                                  return;
                              }
                              if ( !active && mode === 'source' && !init.isWikitextAvailable ) {
                  Severity: Minor
                  Found in modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js - About 1 hr to fix

                    Function syncScalableToType has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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