wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 436 of 912 total issues

Avoid too many return statements within this function.
Open

    return '';
Severity: Major
Found in modules/ve-mw/dm/nodes/ve.dm.MWLanguageVariantNode.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return null;
    Severity: Major
    Found in modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  return;
      Severity: Major
      Found in includes/Hooks.php - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return 'unknown'; // should never happen
        Severity: Major
        Found in modules/ve-mw/dm/nodes/ve.dm.MWLanguageVariantNode.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return variantInfo.oneway[ languageIndex ].t;
          Severity: Major
          Found in modules/ve-mw/dm/nodes/ve.dm.MWLanguageVariantNode.js - About 30 mins to fix

            Function setDefaultMode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            ve.init.mw.ArticleTarget.prototype.setDefaultMode = function () {
                const oldDefaultMode = this.defaultMode;
                // Parent method
                ve.init.mw.ArticleTarget.super.prototype.setDefaultMode.apply( this, arguments );
            
            
            Severity: Minor
            Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 25 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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            ve.ui.MWMediaDialog.prototype.initialize = function () {
                // Parent method
                ve.ui.MWMediaDialog.super.prototype.initialize.call( this );
            
                // Main layout
            Severity: Minor
            Found in modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js - About 25 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 maybeShowMetaDialog has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            ve.init.mw.DesktopArticleTarget.prototype.maybeShowMetaDialog = function () {
                if ( this.welcomeDialogPromise ) {
                    // Pop out the notices when the welcome dialog is closed
                    this.welcomeDialogPromise
                        .always( () => {
            Severity: Minor
            Found in modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js - About 25 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 switchToWikitextEditor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            ve.init.mw.ArticleTarget.prototype.switchToWikitextEditor = function ( modified ) {
                // When switching with changes we always pass the full page as changes in visual section mode
                // can still affect the whole document (e.g. removing a reference)
                if ( modified ) {
                    this.section = null;
            Severity: Minor
            Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 25 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 onPositionCheckboxChange has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            ve.ui.MWMediaDialog.prototype.onPositionCheckboxChange = function ( isSelected ) {
                const currentModelAlignment = this.imageModel.getAlignment();
            
                this.positionSelect.setDisabled( !isSelected );
                this.checkChanged();
            Severity: Minor
            Found in modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js - About 25 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 onSaveDialogReview has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            ve.init.mw.ArticleTarget.prototype.onSaveDialogReview = function () {
                if ( !this.saveDialog.hasDiff ) {
                    this.emit( 'saveReview' );
                    this.saveDialog.pushPending();
                    // Acquire a temporary user username before diffing, so that signatures and
            Severity: Minor
            Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 25 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 getSectionHashFromPage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            ve.init.mw.ArticleTarget.prototype.getSectionHashFromPage = function () {
                // Assume there are section edit links, as the user just did a section edit. This also means
                // that the section numbers line up correctly, as not every H_ tag is a numbered section.
                const $sections = this.$editableContent.find( '.mw-editsection' );
            
            
            Severity: Minor
            Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 25 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 refreshControls has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.refreshControls = function () {
                const partId = this.getSelectedTopLevelPartId(),
                    canBeDeleted = !!partId;
            
                let canMoveUp, canMoveDown = false;
            Severity: Minor
            Found in modules/ve-mw/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.js - About 25 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 resetCaption has a Cognitive Complexity of 6 (exceeds 5 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 25 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 afterActivate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            ve.init.mw.DesktopArticleTarget.prototype.afterActivate = function () {
                $( 'html' ).removeClass( 've-activating' ).addClass( 've-active' );
            
                // Disable TemplateStyles in the original content
                // (We do this here because toggling 've-active' class above hides it)
            Severity: Minor
            Found in modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js - About 25 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 setupSkinTabs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            ve.init.mw.DesktopArticleTarget.prototype.setupSkinTabs = function () {
                if ( this.isViewPage ) {
                    const namespaceNumber = mw.config.get( 'wgNamespaceNumber' );
                    const namespaceName = mw.config.get( 'wgCanonicalNamespace' );
                    const isTalkNamespace = mw.Title.isTalkNamespace( namespaceNumber );
            Severity: Minor
            Found in modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js - About 25 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 getSetupProcess has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            ve.ui.MWAlienExtensionInspector.prototype.getSetupProcess = function ( data ) {
                return ve.ui.MWAlienExtensionInspector.super.prototype.getSetupProcess.call( this, data )
                    .next( () => {
                        const attributes = this.selectedNode.getAttribute( 'mw' ).attrs;
            
            
            Severity: Minor
            Found in modules/ve-mw/ui/inspectors/ve.ui.MWAlienExtensionInspector.js - About 25 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 renderBody has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            ve.ui.MWLanguageVariantNodeContextItem.prototype.renderBody = function () {
                const $body = this.$body,
                    $table = $( '<table>' ),
                    $header = $( '<tr>' ),
                    variantInfo = this.model.getVariantInfo(),
            Severity: Minor
            Found in modules/ve-mw/ui/contextitems/ve.ui.MWLanguageVariantNodeContextItem.js - About 25 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 updateSize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            ve.ui.MWExpandableContentElement.prototype.updateSize = function () {
                this.toggle( true );
            
                if ( Math.floor( this.calculateCurrentTextHeight() / this.getLineHeight() ) > 3 ) {
                    if ( !this.$container ) {
            Severity: Minor
            Found in modules/ve-mw/ui/elements/ve.ui.MWExpandableContentElement.js - About 25 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 toDomElements has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            ve.dm.MWCategoryMetaItem.static.toDomElements = function ( dataElement, doc, converter ) {
                let domElement;
                const category = dataElement.attributes.category || '';
                if ( converter.isForPreview() ) {
                    domElement = doc.createElement( 'a' );
            Severity: Minor
            Found in modules/ve-mw/dm/metaitems/ve.dm.MWCategoryMetaItem.js - About 25 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