wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 436 of 912 total issues

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/ParsoidClient.php - About 45 mins to fix

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

    ve.dm.MWTransclusionNode.static.getWikitext = function ( content ) {
        let wikitext = '';
    
        // Normalize to multi template format
        if ( content.params ) {
    Severity: Minor
    Found in modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.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 ( section ) {
                                    // switching from visual via the "add section" tab
                                    target.switchToWikitextSection( section );
                                } else {
                                    target.editSource();
    Severity: Major
    Found in modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js - About 45 mins to fix

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

              ProperPageIdentity $page,
              UserIdentity $user,
              string $wikitext,
              array &$params,
              array $pluginData,
      Severity: Minor
      Found in includes/VisualEditorHookRunner.php - About 45 mins to fix

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

                ProperPageIdentity $page,
                UserIdentity $user,
                string $wikitext,
                array &$params,
                array $pluginData,
        Severity: Minor
        Found in includes/VisualEditorApiVisualEditorEditPreSaveHook.php - About 45 mins to fix

          Consider simplifying this complex logical expression.
          Open

              if (
                  (
                      ( imageType === 'frameless' || imageType === 'none' ) &&
                      alignment === 'none'
                  ) ||
          Severity: Major
          Found in modules/ve-mw/dm/models/ve.dm.MWImageModel.js - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                if ( attributeChanges.mw.from.parts.length === 1 && attributeChanges.mw.to.parts.length === 1 ) {
                    // Single-template transclusion, before and after. Relatively easy to summarize.
                    // TODO: expand this to well-represent transclusions that contain multiple templates.
            
                    // The bits of a template we care about are deeply-nested inside an
            Severity: Major
            Found in modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                      if ( isVisual && !(
                          lastDiff && lastDiff.oldId === oldId && lastDiff.newId === newId &&
                          lastDiff.oldPageName === oldPageName && lastDiff.newPageName === newPageName
                      ) ) {
                          $visualDiff.empty();
              Severity: Major
              Found in modules/ve-mw/preinit/ve.init.mw.DiffPage.init.js - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                    if ( mode === 'traditional' || mode === 'nolines' || mode === 'slideshow' ) {
                        const imagePadding = ( mode === 'traditional' ? 30 : 0 );
                        innerDivWidth = parseInt( galleryMwAttrs.widths || defaults.imageWidth ) + imagePadding;
                        innerDivHeight = parseInt( galleryMwAttrs.heights || defaults.imageHeight ) + imagePadding;
                        if ( mode === 'traditional' ) {
                Severity: Major
                Found in modules/ve-mw/ce/nodes/ve.ce.MWGalleryImageNode.js - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                              if (
                                  // Modified click (e.g. ctrl+click)
                                  !init.isUnmodifiedLeftClick( e ) ||
                                  // Not an edit action
                                  !( linkUrl.searchParams.has( 'action' ) || linkUrl.searchParams.has( 'veaction' ) ) ||
                  Severity: Major
                  Found in modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                            if (
                                $config->get( 'VisualEditorUseSingleEditTab' ) &&
                                wfTimestampNow() < $config->get( 'VisualEditorSingleEditTabSwitchTimeEnd' ) &&
                                $user->isNamed() &&
                                self::enabledForUser( $user ) &&
                    Severity: Major
                    Found in includes/Hooks.php - About 40 mins to fix

                      Function toggleWrapSelection has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      ve.ui.MWWikitextAction.prototype.toggleWrapSelection = function ( before, after, placeholder, expandOffsetsCallback, unwrapOffsetsCallback ) {
                      Severity: Minor
                      Found in modules/ve-mw/ui/actions/ve.ui.MWWikitextAction.js - About 35 mins to fix

                        Function runScreenshotTest has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            function runScreenshotTest( lang, name, clientScript, padding, teardownScript ) {
                        Severity: Minor
                        Found in build/screenshots.js - About 35 mins to fix

                          Function runMenuTask has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                  runMenuTask: function ( done, tool, expanded, highlight, extraElements ) {
                          Severity: Minor
                          Found in build/screenshots-client/utils.js - About 35 mins to fix

                            Method getHtmlInputTransformHelper has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                    PageIdentity $page,
                                    string $html,
                                    int $oldid = null,
                                    string $etag = null,
                                    Bcp47Code $pageLanguage = null
                            Severity: Minor
                            Found in includes/DirectParsoidClient.php - About 35 mins to fix

                              Function getVisualDiffGeneratorPromise has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                      getVisualDiffGeneratorPromise: function ( oldIdOrPromise, newIdOrPromise, parseDocumentModulePromise, oldPageName, newPageName ) {
                              Severity: Minor
                              Found in modules/ve-mw/preinit/ve.init.mw.DiffLoader.js - About 35 mins to fix

                                Method transformHTML has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                        PageIdentity $page, Bcp47Code $targetLanguage, string $html, ?int $oldid, ?string $etag
                                Severity: Minor
                                Found in includes/DirectParsoidClient.php - About 35 mins to fix

                                  Method getHtmlOutputRendererHelper has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                          PageIdentity $page,
                                          ?RevisionRecord $revision = null,
                                          Bcp47Code $pageLanguage = null,
                                          bool $stash = false,
                                          string $flavor = self::FLAVOR_DEFAULT
                                  Severity: Minor
                                  Found in includes/DirectParsoidClient.php - About 35 mins to fix

                                    Method onPreferencesFormPreSave has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                        public function onPreferencesFormPreSave( $data, $form, $user, &$result, $oldUserOptions ) {
                                    Severity: Minor
                                    Found in includes/Hooks.php - About 35 mins to fix

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

                                              Title $title, string $wikitext, bool $bodyOnly, int $oldid = null, bool $stash = false
                                      Severity: Minor
                                      Found in includes/ApiParsoidTrait.php - About 35 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language