wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 436 of 912 total issues

Function replacePageContent has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    html, categoriesHtml, displayTitle, lastModified, contentSub, sections
Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 45 mins to fix

    Function switchPanels has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    ve.ui.MWMediaDialog.prototype.switchPanels = function ( panel, noFocus ) {
        switch ( panel ) {
            case 'edit':
                this.setSize( this.constructor.static.size );
                // Set the edit panel
    Severity: Minor
    Found in modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js - About 45 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 addPages has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.addPages = function ( pages, index ) {
        const stackLayoutPages = this.stackLayout.getItems();
    
        // Remove pages with same names
        const remove = [];
    Severity: Minor
    Found in modules/ve-mw/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.js - About 45 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 saveComplete has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    ve.init.mw.ArticleTarget.prototype.saveComplete = function ( data ) {
        this.editSummaryValue = null;
        this.initialEditSummary = null;
    
        this.saveDeferred.resolve();
    Severity: Minor
    Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 45 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 onToggleUnusedFields has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    ve.ui.MWTransclusionOutlineTemplateWidget.prototype.onToggleUnusedFields = function ( visibility, fromClick ) {
        if ( visibility ) {
            this.createAllParameterCheckboxes();
        }
    
    
    Severity: Minor
    Found in modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineTemplateWidget.js - About 45 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 getRange has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    ve.ui.MWAceEditorWidget.prototype.getRange = function () {
        let lines;
        function posToOffset( row, col ) {
            let offset = 0;
    
    
    Severity: Minor
    Found in modules/ve-mw/ui/widgets/ve.ui.MWAceEditorWidget.js - About 45 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 onRequestImagesSuccess has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    ve.ui.MWGalleryDialog.prototype.onRequestImagesSuccess = function ( response ) {
        const thumbUrls = {},
            items = [],
            config = { isMobile: this.isMobile, draggable: !this.isReadOnly() };
    
    
    Severity: Minor
    Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js - About 45 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 getActionProcess has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    ve.ui.MWExtensionWindow.prototype.getActionProcess = function ( action, process ) {
        return process.first( () => {
            if ( action === 'done' ) {
                if ( this.constructor.static.allowedEmpty || this.input.getValue() !== '' ) {
                    this.insertOrUpdateNode();
    Severity: Minor
    Found in modules/ve-mw/ui/ve.ui.MWExtensionWindow.js - About 45 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

    Method transformWikitext has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            PageIdentity $page,
            Bcp47Code $targetLanguage,
            string $wikitext,
            bool $bodyOnly,
            ?int $oldid,
    Severity: Minor
    Found in includes/DirectParsoidClient.php - About 45 mins to fix

      Method onSkinEditSectionLinks has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function onSkinEditSectionLinks( $skin, $title, $section,
              $tooltip, &$result, $lang
      Severity: Minor
      Found in includes/Hooks.php - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if ( typeof change === 'string' ) {
                                listItem.appendChild( document.createTextNode( change ) );
                            } else {
                                change.forEach( ( node ) => {
                                    listItem.appendChild( node );
        Severity: Major
        Found in modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js - About 45 mins to fix

          Function onBeforePageDisplay has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function onBeforePageDisplay( $output, $skin ): void {
                  $services = MediaWikiServices::getInstance();
                  $hookRunner = new VisualEditorHookRunner( $services->getHookContainer() );
                  if ( !$hookRunner->onVisualEditorBeforeEditor( $output, $skin ) ) {
                      $output->addJsConfigVars( 'wgVisualEditorDisabledByHook', true );
          Severity: Minor
          Found in includes/Hooks.php - About 45 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 onCustomEditor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function onCustomEditor( $article, $user ) {
                  $req = $article->getContext()->getRequest();
                  $services = MediaWikiServices::getInstance();
                  $urlUtils = $services->getUrlUtils();
                  $veConfig = $services->getConfigFactory()->makeConfig( 'visualeditor' );
          Severity: Minor
          Found in includes/Hooks.php - About 45 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 deeply nested control flow statements.
          Open

                                              if ( data && data.action === 'prefer-ve' ) {
                                                  location.href = veEditUrl;
                                              } else if ( data && data.action === 'multi-tab' ) {
                                                  location.reload();
                                              }
          Severity: Major
          Found in modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js - About 45 mins to fix

            Method onBeforeInitialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    $title, $article, $output, $user, $request, $mediaWiki
            Severity: Minor
            Found in includes/Hooks.php - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if ( !paramChanges ) {
                                      paramChanges = document.createElement( 'ul' );
                                      descriptions.push( paramChanges );
                                  }
              Severity: Major
              Found in modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js - About 45 mins to fix

                Function VeCeMWInlineImageNode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                ve.ce.MWInlineImageNode = function VeCeMWInlineImageNode( model, config ) {
                    let $image;
                    let hasHref = false;
                
                    if ( model.getAttribute( 'isError' ) ) {
                Severity: Minor
                Found in modules/ve-mw/ce/nodes/ve.ce.MWInlineImageNode.js - About 45 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 matchLanguage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                ve.dm.MWLanguageVariantNode.static.matchLanguage = function ( items ) {
                    const userVariant = mw.config.get( 'wgUserVariant' ),
                        fallbacks = mw.config.get( 'wgVisualEditor' ).pageVariantFallbacks,
                        languageCodes =
                            ( userVariant ? [ userVariant ] : [] ).concat( fallbacks || [] );
                Severity: Minor
                Found in modules/ve-mw/dm/nodes/ve.dm.MWLanguageVariantNode.js - About 45 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 deeply nested control flow statements.
                Open

                                                if ( confirmed ) {
                                                    return dataPromise;
                                                } else {
                                                    // If they requested the latest version, invalidate the autosave state
                                                    mw.storage.session.remove( 've-docstate' );
                Severity: Major
                Found in modules/ve-mw/preinit/ve.init.mw.ArticleTargetLoader.js - About 45 mins to fix

                  Function register has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  mw.editcheck.EditCheckFactory.prototype.register = function ( constructor, name ) {
                      name = name || ( constructor.static && constructor.static.name );
                  
                      if ( typeof name !== 'string' || name === '' ) {
                          throw new Error( 'Check names must be strings and must not be empty' );
                  Severity: Minor
                  Found in editcheck/modules/EditCheckFactory.js - About 45 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