wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 912 of 912 total issues

Function onRequestImagesSuccess has 45 lines of code (exceeds 25 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 1 hr to fix

    Function getHtml has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            getHtml: function ( newDoc, oldDoc ) {
                function copyAttributes( from, to ) {
                    Array.prototype.forEach.call( from.attributes, ( attr ) => {
                        to.setAttribute( attr.name, attr.value );
                    } );
    Severity: Minor
    Found in modules/ve-mw/preinit/ve.init.mw.ArticleTargetSaver.js - About 1 hr to fix

      Method parseWikitext has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function parseWikitext( $newRevId, array $params ) {
              $apiParams = [
                  'action' => 'parse',
                  'oldid' => $newRevId,
                  'prop' => 'text|revid|categorieshtml|sections|displaytitle|subtitle|modules|jsconfigvars',
      Severity: Minor
      Found in includes/ApiVisualEditorEdit.php - About 1 hr to fix

        Function describeChanges has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ve.dm.MWTransclusionNode.static.describeChanges = function ( attributeChanges ) {
            const descriptions = [ ve.msg( 'visualeditor-changedesc-mwtransclusion' ) ];
        
            // This method assumes that the behavior of isDiffComparable above remains
            // the same, so it doesn't have to consider whether the actual template
        Severity: Minor
        Found in modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js - About 1 hr to fix

          Function generateContents has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          ve.ce.MWSignatureNode.prototype.generateContents = function () {
              const doc = this.getModel().getDocument();
              let abortable, aborted;
              const abortedPromise = ve.createDeferred().reject( 'http',
                  { textStatus: 'abort', exception: 'abort' } ).promise();
          Severity: Minor
          Found in modules/ve-mw/ce/nodes/ve.ce.MWSignatureNode.js - About 1 hr to fix

            Function initialize has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            ve.ui.EditCheckInspector.prototype.initialize = function () {
                // Parent method
                ve.ui.EditCheckInspector.super.prototype.initialize.call( this );
            
                // Survey panel
            Severity: Minor
            Found in editcheck/modules/EditCheckInspector.js - About 1 hr to fix

              Function act has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              mw.editcheck.AddReferenceEditCheck.prototype.act = function ( choice, action, contextItem ) {
                  // The complex citoid workflow means that we can't just count on a single "windowAction" here...
                  const windowAction = ve.ui.actionFactory.create( 'window', contextItem.context.getSurface(), 'check' );
                  switch ( choice ) {
                      case 'accept':
              Severity: Minor
              Found in editcheck/modules/AddReferenceEditCheck.js - About 1 hr to fix

                Function isSaveable has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                ve.ui.MWGalleryDialog.prototype.isSaveable = function () {
                    // Check attributes
                    if ( this.originalMwDataNormalized ) {
                        const mwDataCopy = ve.copy( this.selectedNode.getAttribute( 'mw' ) );
                        this.updateMwData( mwDataCopy );
                Severity: Minor
                Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.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 wrapText has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                ve.dm.MWWikitextSurfaceFragment.prototype.wrapText = function ( before, after, placeholder, forceWrap ) {
                    placeholder = OO.ui.resolveMsg( placeholder );
                
                    function unwrap( fragment ) {
                        const text = fragment.getText();
                Severity: Minor
                Found in modules/ve-mw/dm/ve.dm.MWWikitextSurfaceFragment.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

                Method __construct has 14 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        ApiMain $main,
                        string $name,
                        RevisionLookup $revisionLookup,
                        TempUserCreator $tempUserCreator,
                        UserFactory $userFactory,
                Severity: Major
                Found in includes/ApiVisualEditor.php - About 1 hr to fix

                  Function syncScalableToType has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                  ve.dm.MWImageNode.static.syncScalableToType = function ( type, mediaType, scalable ) {
                      const defaultThumbSize = mw.config.get( 'wgVisualEditorConfig' )
                          .thumbLimits[ mw.user.options.get( 'thumbsize' ) ];
                  
                      const originalDimensions = scalable.getOriginalDimensions();
                  Severity: Minor
                  Found in modules/ve-mw/dm/nodes/ve.dm.MWImageNode.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

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

                  ve.dm.MWImageNode.static.isDiffComparable = function ( element, other ) {
                      // Images with different src's shouldn't be diffed
                      return element.type === other.type && element.attributes.resource === other.attributes.resource;
                  };
                  Severity: Major
                  Found in modules/ve-mw/dm/nodes/ve.dm.MWImageNode.js and 1 other location - About 1 hr to fix
                  modules/ve-mw/dm/nodes/ve.dm.MWGalleryImageNode.js on lines 274..277

                  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 70.

                  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.MWGalleryImageNode.static.isDiffComparable = function ( element, other ) {
                      // Images with different src's shouldn't be diffed
                      return element.type === other.type && element.attributes.resource === other.attributes.resource;
                  };
                  Severity: Major
                  Found in modules/ve-mw/dm/nodes/ve.dm.MWGalleryImageNode.js and 1 other location - About 1 hr to fix
                  modules/ve-mw/dm/nodes/ve.dm.MWImageNode.js on lines 120..123

                  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 70.

                  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 fetchSpecialCharList has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  ve.init.mw.Platform.prototype.fetchSpecialCharList = function () {
                      return mw.loader.using( 'mediawiki.language.specialCharacters' ).then( () => {
                          const specialCharacterGroups = require( 'mediawiki.language.specialCharacters' ),
                              characters = {},
                              otherGroupName = mw.msg( 'visualeditor-special-characters-group-other' ),
                  Severity: Minor
                  Found in modules/ve-mw/init/ve.init.mw.Platform.js - About 1 hr to fix

                    Function resolveChangeQueue has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        ve.dm.MWTransclusionModel.prototype.resolveChangeQueue = function ( queue ) {
                            const resolveQueue = [];
                    
                            for ( let i = 0; i < queue.length; i++ ) {
                                const item = queue[ i ];
                    Severity: Minor
                    Found in modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js - About 1 hr to fix

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

                      ve.ui.MWExportWikitextDialog.prototype.initialize = function () {
                          // Parent method
                          ve.ui.MWExportWikitextDialog.super.prototype.initialize.call( this );
                      
                          this.titleInput = new mw.widgets.TitleInputWidget( {
                      Severity: Minor
                      Found in modules/ve-mw-collab/ve.ui.MWExportWikitextDialog.js - About 1 hr to fix

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

                        ve.ui.MWLinkNodeInspector.prototype.getTeardownProcess = function ( data ) {
                            data = data || {};
                            return ve.ui.MWLinkNodeInspector.super.prototype.getTeardownProcess.call( this, data )
                                .first( () => {
                                    let value = this.targetInput.getValue();
                        Severity: Minor
                        Found in modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js - About 1 hr to fix

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

                          ve.init.mw.DesktopArticleTarget = function VeInitMwDesktopArticleTarget( config ) {
                              // Parent constructor
                              ve.init.mw.DesktopArticleTarget.super.call( this, config );
                          
                              // Parent constructor bound key event handlers, but we don't want them bound until
                          Severity: Minor
                          Found in modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js - About 1 hr to fix

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

                            ve.ui.MWAddParameterPage.prototype.initialize = function () {
                                this.template
                                    .connect( this, {
                                        // There is a "change" event, but it triggers way to often even for content changes
                                        add: 'onTemplateParametersChanged',
                            Severity: Minor
                            Found in modules/ve-mw/ui/pages/ve.ui.MWAddParameterPage.js - About 1 hr to fix

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

                              ve.ui.MWSaveDialog.prototype.setDiffAndReview = function ( wikitextDiffPromise, visualDiffGeneratorPromise, baseDoc ) {
                                  this.clearDiff();
                              
                                  function createDiffElement( visualDiff ) {
                                      const diffElement = new ve.ui.DiffElement( visualDiff );
                              Severity: Minor
                              Found in modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language