wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 436 of 912 total issues

Function activateTarget has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function activateTarget( mode, section, tPromise, modified ) {
        let dataPromise;

        updateTabs( true, mode, section === 'new' );

Severity: Major
Found in modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js - About 3 hrs to fix

    Function toDataElement has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    ve.dm.MWBlockImageNode.static.toDataElement = function ( domElements, converter ) {
        const figure = domElements[ 0 ];
        const img = figure.querySelector( '.mw-file-element' ); // <img>, <video>, <audio>, or <span> if mw:Error
        // Images copied from the old parser output can have typeof=mw:Image but no resource information. T337438
        if ( !img || !img.hasAttribute( 'resource' ) ) {
    Severity: Minor
    Found in modules/ve-mw/dm/nodes/ve.dm.MWBlockImageNode.js - About 3 hrs 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 createValueInput has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    ve.ui.MWParameterPage.prototype.createValueInput = function () {
        const type = this.parameter.getType(),
            value = this.parameter.getValue(),
            valueInputConfig = this.getDefaultInputConfig();
    
    
    Severity: Minor
    Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js - About 3 hrs 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

    Method onSkinEditSectionLinks has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function onSkinEditSectionLinks( $skin, $title, $section,
            $tooltip, &$result, $lang
        ) {
            $services = MediaWikiServices::getInstance();
            $userOptionsLookup = $services->getUserOptionsLookup();
    Severity: Major
    Found in includes/Hooks.php - About 3 hrs to fix

      Method execute has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function execute( $subPage ) {
              $this->setHeaders();
              $this->checkPermissions();
      
              $output = $this->getOutput();
      Severity: Major
      Found in includes/SpecialCollabPad.php - About 3 hrs to fix

        Function createScreenshotEnvironment has 80 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function createScreenshotEnvironment( test ) {
            let clientSize, driver;
        
            test.beforeEach( function () {
                const lang = this.currentTest.parent.lang || 'en';
        Severity: Major
        Found in build/screenshots.js - About 3 hrs to fix

          Function teardown has 79 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          ve.ui.MWAdvancedSettingsPage.prototype.teardown = function ( data ) {
              // Data initialization
              data = data || {};
              if ( data.action !== 'done' ) {
                  return;
          Severity: Major
          Found in modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js - About 3 hrs to fix

            Function restorePage has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

            ve.init.mw.DesktopArticleTarget.prototype.restorePage = function () {
                // Restore any previous redirectMsg/redirectsub
                this.setRealRedirectInterface();
                if ( this.$originalCategories ) {
                    $( '#catlinks' ).replaceWith( this.$originalCategories );
            Severity: Minor
            Found in modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js - About 3 hrs 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 toDataElement has 77 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            ve.dm.MWBlockImageNode.static.toDataElement = function ( domElements, converter ) {
                const figure = domElements[ 0 ];
                const img = figure.querySelector( '.mw-file-element' ); // <img>, <video>, <audio>, or <span> if mw:Error
                // Images copied from the old parser output can have typeof=mw:Image but no resource information. T337438
                if ( !img || !img.hasAttribute( 'resource' ) ) {
            Severity: Major
            Found in modules/ve-mw/dm/nodes/ve.dm.MWBlockImageNode.js - About 3 hrs to fix

              Function toDataElement has 74 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              ve.dm.MWInlineImageNode.static.toDataElement = function ( domElements, converter ) {
                  const container = domElements[ 0 ]; // <span>
                  if ( !container.children.length ) {
                      // Malformed image, alienate (T267282)
                      return null;
              Severity: Major
              Found in modules/ve-mw/dm/nodes/ve.dm.MWInlineImageNode.js - About 2 hrs to fix

                Method getAllowedParams has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getAllowedParams() {
                        return [
                            'paction' => [
                                ParamValidator::PARAM_REQUIRED => true,
                                ParamValidator::PARAM_TYPE => [
                Severity: Major
                Found in includes/ApiVisualEditorEdit.php - About 2 hrs to fix

                  Function VeUiMWTemplatePage has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  ve.ui.MWTemplatePage = function VeUiMWTemplatePage( template, name, config ) {
                      const link = template.getTemplateDataQueryTitle();
                  
                      // Configuration initialization
                      config = ve.extendObject( {
                  Severity: Major
                  Found in modules/ve-mw/ui/pages/ve.ui.MWTemplatePage.js - About 2 hrs to fix

                    Function addExactMatch has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    ve.ui.MWTemplateTitleInputWidget.prototype.addExactMatch = function ( response ) {
                        const query = this.getQueryValue(),
                            title = mw.Title.newFromText( query, this.namespace );
                        // No point in trying anything when the title is invalid
                        if ( !title ) {
                    Severity: Major
                    Found in modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js - About 2 hrs to fix

                      Function getVisualDiffGeneratorPromise has a Cognitive Complexity of 20 (exceeds 5 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 2 hrs 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 exports has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                      module.exports = function () {
                          const veDone = arguments[ arguments.length - 1 ];
                      
                          window.seleniumUtils = {
                              getBoundingRect: function ( elements ) {
                      Severity: Minor
                      Found in build/screenshots-client/utils.js - About 2 hrs 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 getActionProcess has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      ve.ui.MWMediaDialog.prototype.getActionProcess = function ( action ) {
                          let handler;
                      
                          switch ( action ) {
                              case 'change':
                      Severity: Major
                      Found in modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js - About 2 hrs to fix

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

                        /**
                         * Container for a template as rendered in the template dialog sidebar.
                         * Contains search and visibility inputs, and a list of parameters when available.
                         *
                         * @class
                        Severity: Minor
                        Found in modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineTemplateWidget.js - About 2 hrs to fix

                          Function getLookupRequest has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          ve.ui.MWTemplateTitleInputWidget.prototype.getLookupRequest = function () {
                              let promise = ve.ui.MWTemplateTitleInputWidget.super.prototype.getLookupRequest.call( this );
                              if ( mw.config.get( 'wgVisualEditorConfig' ).cirrusSearchLookup ) {
                                  promise = promise
                                      .then( this.addExactMatch.bind( this ) )
                          Severity: Major
                          Found in modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js - About 2 hrs to fix

                            Function saveComplete has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            ve.init.mw.ArticleTarget.prototype.saveComplete = function ( data ) {
                                this.editSummaryValue = null;
                                this.initialEditSummary = null;
                            
                                this.saveDeferred.resolve();
                            Severity: Major
                            Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 2 hrs to fix

                              Function createValueInput has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              ve.ui.MWParameterPage.prototype.createValueInput = function () {
                                  const type = this.parameter.getType(),
                                      value = this.parameter.getValue(),
                                      valueInputConfig = this.getDefaultInputConfig();
                              
                              
                              Severity: Major
                              Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js - About 2 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language