wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 912 of 912 total issues

Function VeDmMWImageModel has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

ve.dm.MWImageModel = function VeDmMWImageModel( parentDoc, config ) {
    config = config || {};

    // Mixin constructors
    OO.EventEmitter.call( this );
Severity: Minor
Found in modules/ve-mw/dm/models/ve.dm.MWImageModel.js - About 1 hr to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    ve.ui.MWGalleryDialog = function VeUiMWGalleryDialog() {
        // Parent constructor
        ve.ui.MWGalleryDialog.super.apply( this, arguments );
    
        this.$element.addClass( 've-ui-mwGalleryDialog' );
    Severity: Major
    Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js and 1 other location - About 1 hr to fix
    modules/ve-mw/ui/dialogs/ve.ui.MWPreDialog.js on lines 17..22

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 68.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    ve.ui.MWPreDialog = function VeUiMWPreDialog() {
        // Parent constructor
        ve.ui.MWPreDialog.super.apply( this, arguments );
    
        this.$element.addClass( 've-ui-mwPreDialog' );
    Severity: Major
    Found in modules/ve-mw/ui/dialogs/ve.ui.MWPreDialog.js and 1 other location - About 1 hr to fix
    modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js on lines 17..22

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 68.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        this.displayTitleField = new OO.ui.FieldLayout(
            this.displayTitleInput,
            {
                $overlay: config.$overlay,
                align: 'top',
    Severity: Major
    Found in modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js and 1 other location - About 1 hr to fix
    modules/ve-mw/ui/pages/ve.ui.MWCategoriesPage.js on lines 59..67

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 68.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        this.defaultSort = new OO.ui.FieldLayout(
            this.defaultSortInput,
            {
                $overlay: config.$overlay,
                align: 'top',
    Severity: Major
    Found in modules/ve-mw/ui/pages/ve.ui.MWCategoriesPage.js and 1 other location - About 1 hr to fix
    modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js on lines 91..99

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 68.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function initAutosave has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    ve.init.mw.Target.prototype.initAutosave = function ( config ) {
        // Old function signature
        // TODO: Remove after fixed downstream
        if ( typeof config === 'boolean' ) {
            config = { suppressNotification: config };
    Severity: Minor
    Found in modules/ve-mw/init/targets/ve.init.mw.Target.js - About 1 hr to fix

      Function createItem has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ve.ui.MWLanguageVariantOneWayInspector.prototype.createItem = function ( from, lang, to ) {
          const fromTextTarget = this.createTextTarget( OO.ui.msg(
              'visualeditor-mwlanguagevariantinspector-oneway-from-text-placeholder'
          ) );
          const languageInput = new ve.ui.LanguageInputWidget( {
      Severity: Minor
      Found in modules/ve-mw/ui/inspectors/ve.ui.MWLanguageVariantInspector.js - About 1 hr to fix

        Function processQueue has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ve.init.mw.ApiResponseCache.prototype.processQueue = function () {
            const rejectSubqueue = ( rejectQueue ) => {
                for ( let i = 0, len = rejectQueue.length; i < len; i++ ) {
                    this.deferreds[ rejectQueue[ i ] ].reject();
                }
        Severity: Minor
        Found in modules/ve-mw/init/apiresponsecache/ve.init.mw.ApiResponseCache.js - About 1 hr to fix

          Function VeUiMwEducationPopup has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          ve.ui.MWEducationPopupWidget = function VeUiMwEducationPopup( $target, config ) {
              config = config || {};
          
              // HACK: Do not display on platforms other than desktop
              if ( !( ve.init.mw.DesktopArticleTarget && ve.init.target instanceof ve.init.mw.DesktopArticleTarget ) ) {
          Severity: Minor
          Found in modules/ve-mw/ui/widgets/ve.ui.MWEducationPopupWidget.js - About 1 hr to fix

            Function insertImageNode has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            ve.dm.MWImageModel.prototype.insertImageNode = function ( fragment ) {
                const nodeType = this.getImageNodeType(),
                    surfaceModel = fragment.getSurface();
            
                if ( !( fragment.getSelection() instanceof ve.dm.LinearSelection ) ) {
            Severity: Minor
            Found in modules/ve-mw/dm/models/ve.dm.MWImageModel.js - About 1 hr to fix

              Function switchToFallbackWikitextEditor has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              ve.init.mw.DesktopArticleTarget.prototype.switchToFallbackWikitextEditor = function ( modified ) {
                  const oldId = mw.config.get( 'wgRevisionId' ) || $( 'input[name=parentRevId]' ).val();
                  const prefPromise = mw.libs.ve.setEditorPreference( 'wikitext' );
              
                  if ( !modified ) {
              Severity: Minor
              Found in modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js - About 1 hr to fix

                Method onBeforePageDisplay has 40 lines of code (exceeds 25 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 1 hr to fix

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  ve.dm.MWGalleryImageCaptionNode.static.toDomElements = function ( dataElement, doc ) {
                      const div = doc.createElement( 'div' );
                      div.classList.add( 'gallerytext' );
                      return [ div ];
                  };
                  Severity: Major
                  Found in modules/ve-mw/dm/nodes/ve.dm.MWGalleryImageCaptionNode.js and 1 other location - About 1 hr to fix
                  modules/ve-mw/dm/nodes/ve.dm.MWGalleryCaptionNode.js on lines 37..41

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 67.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  ve.init.mw.DesktopArticleTarget.prototype.setupToolbarSaveButton = function () {
                      this.toolbarSaveButton = this.toolbar.getToolGroupByName( 'save' ).items[ 0 ];
                  };
                  modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js on lines 490..492

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 67.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  ve.init.mw.MobileArticleTarget.prototype.setupToolbarSaveButton = function () {
                      this.toolbarSaveButton = this.toolbar.getToolGroupByName( 'save' ).items[ 0 ];
                  };
                  modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js on lines 294..296

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 67.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  ve.dm.MWGalleryCaptionNode.static.toDomElements = function ( dataElement, doc ) {
                      const li = doc.createElement( 'li' );
                      li.classList.add( 'gallerycaption' );
                      return [ li ];
                  };
                  Severity: Major
                  Found in modules/ve-mw/dm/nodes/ve.dm.MWGalleryCaptionNode.js and 1 other location - About 1 hr to fix
                  modules/ve-mw/dm/nodes/ve.dm.MWGalleryImageCaptionNode.js on lines 31..35

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 67.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Function initAutosave has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                  ve.init.mw.Target.prototype.initAutosave = function ( config ) {
                      // Old function signature
                      // TODO: Remove after fixed downstream
                      if ( typeof config === 'boolean' ) {
                          config = { suppressNotification: config };
                  Severity: Minor
                  Found in modules/ve-mw/init/targets/ve.init.mw.Target.js - About 1 hr 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 updateRedirectInterface has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                  ve.init.mw.ArticleTarget.prototype.updateRedirectInterface = function ( $sub, $msg ) {
                      // For the subtitle, replace the real one with ours.
                      // This is more complicated than it should be because we have to fiddle with the <br>.
                      const $currentSub = $( '#redirectsub' );
                      if ( $currentSub.length ) {
                  Severity: Minor
                  Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 1 hr 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 onSelect has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                  ve.ui.MWFeedbackDialogTool.prototype.onSelect = function () {
                      this.setActive( false );
                  
                      if ( !this.feedbackPromise ) {
                          this.feedbackPromise = mw.loader.using( 'mediawiki.feedback' ).then( () => {
                  Severity: Minor
                  Found in modules/ve-mw/ui/toolgroups/ve.ui.MWHelpListToolGroup.js - About 1 hr 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 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                  ve.ui.MWSaveDialog.prototype.getSetupProcess = function ( data ) {
                      return ve.ui.MWSaveDialog.super.prototype.getSetupProcess.call( this, data )
                          .next( () => {
                              const surfaceMode = ve.init.target.getSurface().getMode();
                  
                  
                  Severity: Minor
                  Found in modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js - About 1 hr 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