wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 912 of 912 total issues

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

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

        ve.ui.MWLanguageVariantDisabledInspector.prototype.getReadyProcess = function ( data ) {
            return ve.ui.MWLanguageVariantDisabledInspector.super.prototype.getReadyProcess.call( this, data )
                .next( () => {
                    this.textTarget.focus();
                } );
        modules/ve-mw/ui/inspectors/ve.ui.MWLanguageVariantInspector.js on lines 514..519

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

        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.MWLanguageVariantFilterInspector.prototype.getReadyProcess = function ( data ) {
            return ve.ui.MWLanguageVariantFilterInspector.super.prototype.getReadyProcess.call( this, data )
                .next( () => {
                    this.textTarget.focus();
                } );
        modules/ve-mw/ui/inspectors/ve.ui.MWLanguageVariantInspector.js on lines 337..342

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

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

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

            ve.dm.MWGalleryImageNode.static.toDomElements = function ( data, doc, converter ) {
                // ImageNode:
                //   <li> li (gallerybox)
                //     <div> thumbDiv
                //       <span> container
            Severity: Major
            Found in modules/ve-mw/dm/nodes/ve.dm.MWGalleryImageNode.js - About 2 hrs to fix

              Function renderCategories has 65 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              ve.init.mw.ArticleTarget.prototype.renderCategories = function ( categoryItems ) {
                  const promises = [],
                      categories = { hidden: {}, normal: {} };
                  categoryItems.forEach( ( categoryItem, index ) => {
                      const attributes = ve.copy( ve.getProp( categoryItem, 'element', 'attributes' ) );
              Severity: Major
              Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 2 hrs to fix

                Function showSaveDialog has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                ve.init.mw.ArticleTarget.prototype.showSaveDialog = function ( action, checkboxName ) {
                    let firstLoad = false;
                
                    if ( !this.isSaveable() || this.saveDialogIsOpening ) {
                        return;
                Severity: Major
                Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 2 hrs to fix

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

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

                    Function toDomElements has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    ve.dm.MWTransclusionNode.static.toDomElements = function ( dataElement, doc, converter ) {
                        const store = converter.getStore(),
                            originalMw = dataElement.attributes.originalMw,
                            originalDomElements = store.value( dataElement.originalDomElementsHash );
                    
                    
                    Severity: Major
                    Found in modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js - About 2 hrs to fix

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

                          this.highlightedCaptionTarget = ve.init.target.createTargetWidget( {
                              includeCommands: this.constructor.static.includeCommands,
                              excludeCommands: this.constructor.static.excludeCommands,
                              importRules: this.constructor.static.getImportRules(),
                              multiline: false
                      Severity: Major
                      Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js and 1 other location - About 2 hrs to fix
                      modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js on lines 288..293

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

                      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.captionTarget = ve.init.target.createTargetWidget( {
                              includeCommands: this.constructor.static.includeCommands,
                              excludeCommands: this.constructor.static.excludeCommands,
                              importRules: this.constructor.static.getImportRules(),
                              multiline: false
                      Severity: Major
                      Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js and 1 other location - About 2 hrs to fix
                      modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js on lines 222..227

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

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

                      ve.dm.MWInlineImageNode.static.toDomElements = function ( dataElement, doc, converter ) {
                          const attributes = dataElement.attributes,
                              container = doc.createElement( 'span' ),
                              imgWrapper = doc.createElement( attributes.href ? 'a' : 'span' ),
                              img = doc.createElement( attributes.isError ? 'span' : attributes.mediaTag ),
                      Severity: Major
                      Found in modules/ve-mw/dm/nodes/ve.dm.MWInlineImageNode.js - About 2 hrs to fix

                        Function restoreEditSection has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                        Open

                        ve.init.mw.ArticleTarget.prototype.restoreEditSection = function () {
                            const section = this.section !== null ? this.section : this.visibleSection;
                            const surface = this.getSurface();
                            const mode = surface.getMode();
                        
                        
                        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 buildMediaInfoPanel has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                        Open

                        ve.ui.MWMediaDialog.prototype.buildMediaInfoPanel = function ( imageinfo ) {
                            const contentDirection = this.getFragment().getDocument().getDir(),
                                imageTitleText = imageinfo.title || imageinfo.canonicaltitle,
                                imageTitle = new OO.ui.LabelWidget( {
                                    label: mw.Title.newFromText( imageTitleText ).getNameText()
                        Severity: Minor
                        Found in modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.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 VeUiMWMediaInfoFieldWidget has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                        Open

                        ve.ui.MWMediaInfoFieldWidget = function VeUiMWMediaInfoFieldWidget( content, config ) {
                            // Configuration initialization
                            config = config || {};
                        
                            // Parent constructor
                        Severity: Minor
                        Found in modules/ve-mw/ui/widgets/ve.ui.MWMediaInfoFieldWidget.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 toDataElement has a Cognitive Complexity of 19 (exceeds 5 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: Minor
                        Found in modules/ve-mw/dm/nodes/ve.dm.MWInlineImageNode.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 toDomElements has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        ve.dm.MWBlockImageNode.static.toDomElements = function ( data, doc, converter ) {
                            const dataElement = data[ 0 ],
                                attributes = dataElement.attributes,
                                figure = doc.createElement( 'figure' ),
                                imgWrapper = doc.createElement( attributes.href ? 'a' : 'span' ),
                        Severity: Major
                        Found in modules/ve-mw/dm/nodes/ve.dm.MWBlockImageNode.js - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language