wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 912 of 912 total issues

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

    ve.ui.MWLanguageVariantFilterInspector.prototype.initialize = function () {
        ve.ui.MWLanguageVariantFilterInspector.super.prototype.initialize.call( this );
        this.textTarget = this.createTextTarget( OO.ui.msg(
            'visualeditor-mwlanguagevariantinspector-filter-text-placeholder'
        ) );
    Severity: Minor
    Found in modules/ve-mw/ui/inspectors/ve.ui.MWLanguageVariantInspector.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 VeUiMWTransclusionOutlinePartWidget has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ve.ui.MWTransclusionOutlinePartWidget = function VeUiMWTransclusionOutlinePartWidget( part, config ) {
            this.part = part;
        
            // Parent constructor
            ve.ui.MWTransclusionOutlinePartWidget.super.call( this, ve.extendObject( config, {
        Severity: Minor
        Found in modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlinePartWidget.js - About 1 hr to fix

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

          ve.ui.MWCategoryWidget = function VeUiMWCategoryWidget( config ) {
              // Config initialization
              config = config || {};
          
              // Parent constructor
          Severity: Minor
          Found in modules/ve-mw/ui/widgets/ve.ui.MWCategoryWidget.js - About 1 hr to fix

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

            ve.dm.MWImageModel.prototype.getUpdatedAttributes = function () {
                const origAttrs = this.getOriginalImageAttributes();
            
                let currentDimensions;
                // Adjust default dimensions if size is set to default
            Severity: Minor
            Found in modules/ve-mw/dm/models/ve.dm.MWImageModel.js - About 1 hr to fix

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

                  function setEditorPreference( editor ) {
                      // If visual mode isn't available, don't set the editor preference as the
                      // user has expressed no choice by opening this editor. (T246259)
                      // Strictly speaking the same thing should happen if visual mode is
                      // available but source mode isn't, but that is never the case.
              Severity: Minor
              Found in modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js - About 1 hr to fix

                Function getPreviewHtml has 32 lines of code (exceeds 25 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

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

                  mw.libs.ve.reduplicateStyles = function ( element ) {
                      Array.prototype.forEach.call( element.querySelectorAll( 'link[rel~="mw-deduplicated-inline-style"]' ), ( link ) => {
                          const href = link.getAttribute( 'href' );
                          if ( !href || href.slice( 0, 'mw-data:'.length ) !== 'mw-data:' ) {
                              return;
                  Severity: Minor
                  Found in modules/ve-mw/preinit/ve.utils.parsoid.js - About 1 hr to fix

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

                    ve.ui.MWMediaDialog.prototype.getSetupProcess = function ( data ) {
                        return ve.ui.MWMediaDialog.super.prototype.getSetupProcess.call( this, data )
                            .next( () => {
                                const isReadOnly = this.isReadOnly();
                    
                    
                    Severity: Minor
                    Found in modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.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 VeUiMWWikitextSurface has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    ve.ui.MWWikitextSurface = function VeUiMWWikitextSurface() {
                        // Parent constructor
                        ve.ui.MWWikitextSurface.super.apply( this, arguments );
                    
                        // Initialization
                    Severity: Minor
                    Found in modules/ve-mw/ui/ve.ui.MWWikitextSurface.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 teardown has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    ve.init.mw.DesktopArticleTarget.prototype.teardown = function ( trackMechanism ) {
                        // Event tracking
                        let abortType, abortedMode;
                        if ( trackMechanism ) {
                            if ( this.activating ) {
                    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 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 insertImageNode has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    ve.dm.MWImageModel.prototype.insertImageNode = function ( fragment ) {
                        const nodeType = this.getImageNodeType(),
                            surfaceModel = fragment.getSurface();
                    
                        if ( !( fragment.getSelection() instanceof ve.dm.LinearSelection ) ) {
                    Severity: Minor
                    Found in modules/ve-mw/dm/models/ve.dm.MWImageModel.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 changeImageSource has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    ve.dm.MWImageModel.prototype.changeImageSource = function ( attrs, APIinfo ) {
                        this.changedImageSource = true;
                    
                        if ( attrs.mediaType ) {
                            this.setMediaType( attrs.mediaType );
                    Severity: Minor
                    Found in modules/ve-mw/dm/models/ve.dm.MWImageModel.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 getPartsList has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    ve.dm.MWTransclusionNode.prototype.getPartsList = function () {
                        if ( !this.partsList ) {
                            this.partsList = [];
                            const content = this.getAttribute( 'mw' );
                            for ( let i = 0; i < content.parts.length; i++ ) {
                    Severity: Minor
                    Found in modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.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

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

                    ve.ui.MWGalleryDialog.prototype.updateActions = function () {
                        this.actions.setAbilities( { done: this.isSaveable() } );
                    };
                    Severity: Major
                    Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js and 1 other location - About 1 hr to fix
                    modules/ve-mw/ui/ve.ui.MWExtensionWindow.js on lines 161..163

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

                    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.MWExtensionWindow.prototype.updateActions = function () {
                        this.actions.setAbilities( { done: this.isSaveable() } );
                    };
                    Severity: Major
                    Found in modules/ve-mw/ui/ve.ui.MWExtensionWindow.js and 1 other location - About 1 hr to fix
                    modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js on lines 927..929

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

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

                    ve.ui.MWWikitextAction.prototype.wrapLine = function ( before, after, placeholder, unwrapOffsetsCallback ) {
                        let originalFragment = this.surface.getModel().getFragment( null, false, true /* excludeInsertions */ );
                        const selectedNodes = originalFragment.getLeafNodes();
                    
                        let unwrapped = false;
                    Severity: Minor
                    Found in modules/ve-mw/ui/actions/ve.ui.MWWikitextAction.js - About 1 hr to fix

                      Function export has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      ve.ui.MWExportWikitextDialog.prototype.export = function () {
                          const wikitext = this.wikitextLayout.textInput.getValue(),
                              title = this.titleInput.getMWTitle(),
                              importTitle = ve.init.target.getImportTitle();
                      
                      
                      Severity: Minor
                      Found in modules/ve-mw-collab/ve.ui.MWExportWikitextDialog.js - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language