wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 436 of 912 total issues

Function unwrapParsoidSections has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

mw.libs.ve.unwrapParsoidSections = function ( element, keepSection ) {
    Array.prototype.forEach.call( element.querySelectorAll( 'section[data-mw-section-id]' ), ( section ) => {
        const parent = section.parentNode,
            sectionId = section.getAttribute( 'data-mw-section-id' );
        // Copy section ID to first child (should be a heading)
Severity: Minor
Found in modules/ve-mw/preinit/ve.utils.parsoid.js - About 35 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 reduplicateStyles has a Cognitive Complexity of 7 (exceeds 5 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 35 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

Avoid too many return statements within this function.
Open

        return mw.user.options.set( keyOrValueMap, jsonValue );
Severity: Major
Found in modules/ve-mw/init/ve.init.mw.Platform.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        return this.getApi().get( {
            action: 'query',
            // Can't use a direct lookup by title because we need this to be case-insensitive
            generator: 'prefixsearch',
            gpssearch: query,
    Severity: Major
    Found in modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return new ve.ui.MWParameterCheckboxInputWidget( valueInputConfig );
      Severity: Major
      Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return ve.ui.MWExternalLinkAnnotationWidget.static.createExternalLinkInputWidget( valueInputConfig );
        Severity: Major
        Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return new ve.ui.MWLazyMultilineTextInputWidget( valueInputConfig );
          Severity: Major
          Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return new ve.ui.MWLazyMultilineTextInputWidget( ve.extendObject( {
                    rows: 1,
                    autosize: true,
                    allowLinebreaks: false
                }, valueInputConfig ) );
            Severity: Major
            Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                              return true;
              Severity: Major
              Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return false;
                Severity: Major
                Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return new OO.ui.ComboBoxInputWidget( valueInputConfig );
                  Severity: Major
                  Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return false;

                      Avoid too many return statements within this function.
                      Open

                          return returnExternalData();
                      Severity: Major
                      Found in modules/ve-mw/preinit/ve.utils.parsoid.js - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return self::getLastEditor( $user, $req );
                        Severity: Major
                        Found in includes/Hooks.php - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return 'oneway';
                          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 true;
                            Severity: Major
                            Found in editcheck/modules/BaseEditCheck.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      return false;
                              Severity: Major
                              Found in editcheck/modules/BaseEditCheck.js - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                        return true;
                                Severity: Major
                                Found in includes/Hooks.php - 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 variantInfo.twoway[ languageIndex ].t;
                                    Severity: Major
                                    Found in modules/ve-mw/dm/nodes/ve.dm.MWLanguageVariantNode.js - About 30 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language