wikimedia/mediawiki-extensions-VisualEditor

View on GitHub
modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js

Summary

Maintainability
D
2 days
Test Coverage

File ve.ui.MWTransclusionDialog.js has 383 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 * VisualEditor user interface MWTransclusionDialog class.
 *
 * @copyright See AUTHORS.txt
 * @license The MIT License (MIT); see LICENSE.txt
Severity: Minor
Found in modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js - About 5 hrs to fix

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

    ve.ui.MWTransclusionDialog.prototype.toggleSidebar = function ( expandSidebar ) {
        if ( this.isSidebarExpanded === expandSidebar ) {
            return;
        }
    
    
    Severity: Minor
    Found in modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js - About 1 hr to fix

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

      ve.ui.MWTransclusionDialog.prototype.getActionProcess = function ( action ) {
          const willLoseProgress = this.getMode() === 'insert' ?
              // A new template with no parameters is not considered valuable.
              this.transclusionModel.containsValuableData() :
              // The user has changed a parameter, and is not on the template search page.
      Severity: Minor
      Found in modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js - About 1 hr to fix

        Function initialize has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ve.ui.MWTransclusionDialog.prototype.initialize = function () {
            // Parent method
            ve.ui.MWTransclusionDialog.super.prototype.initialize.call( this );
        
            this.setupHotkeyTriggers();
        Severity: Minor
        Found in modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.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

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

            ve.ui.MWTransclusionDialog.prototype.addWikitext = function () {
                this.addPart( new ve.dm.MWTransclusionContentModel( this.transclusionModel ) );
            };
            Severity: Major
            Found in modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js and 1 other location - About 1 hr to fix
            modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js on lines 125..127

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

            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.MWTransclusionDialog.prototype.addTemplatePlaceholder = function () {
                this.addPart( new ve.dm.MWTemplatePlaceholderModel( this.transclusionModel ) );
            };
            Severity: Major
            Found in modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js and 1 other location - About 1 hr to fix
            modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js on lines 134..136

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

            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.bookletLayout.getPagesOrdered().forEach( ( page ) => {
                        if ( page instanceof ve.ui.MWParameterPage ) {
                            page.updateSize();
                        }
                    } );
            Severity: Major
            Found in modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js and 1 other location - About 1 hr to fix
            modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js on lines 73..77

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

            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

                            return new OO.ui.Process( () => {
                                this.closeConfirm( ve.msg( 'visualeditor-dialog-transclusion-close-confirmation-prompt' ) ).then( ( confirmed ) => {
                                    if ( confirmed ) {
                                        this.close();
                                    }
            Severity: Minor
            Found in modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js and 1 other location - About 55 mins to fix
            modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js on lines 461..467

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

            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

                            if ( willLoseProgress ) {
                                this.closeConfirm( ve.msg( 'visualeditor-dialog-transclusion-back-confirmation-prompt' ) ).then( ( confirmed ) => {
                                    if ( confirmed ) {
                                        this.resetDialog();
                                    }
            Severity: Minor
            Found in modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js and 1 other location - About 55 mins to fix
            modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js on lines 478..484

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

            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

                if ( !page && part instanceof ve.dm.MWTransclusionContentModel ) {
                    return new ve.ui.MWTransclusionContentPage( part, part.getId(), { $overlay: this.$overlay, isReadOnly: this.isReadOnly() } );
                }
            Severity: Minor
            Found in modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js and 1 other location - About 45 mins to fix
            modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js on lines 238..246

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

            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