wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 912 of 912 total issues

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

    this.metaItemCheckboxes.forEach( ( metaItemCheckbox ) => {
        const currentItem = this.getMetaItem( metaItemCheckbox.metaName ),
            isSelected = metaItemCheckbox.fieldLayout.getField().isSelected();

        if ( currentItem && !isSelected ) {
Severity: Major
Found in modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js and 1 other location - About 4 hrs to fix
modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js on lines 401..410

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

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

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

    this.metaItemCheckboxes.forEach( ( metaItemCheckbox ) => {
        const currentItem = this.getMetaItem( metaItemCheckbox.metaName ),
            isSelected = metaItemCheckbox.fieldLayout.getField().isSelected();

        if ( currentItem && !isSelected ) {
Severity: Major
Found in modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js and 1 other location - About 4 hrs to fix
modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js on lines 334..343

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

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

    if ( APIinfo ) {
        this.scalable.setOriginalDimensions( {
            width: APIinfo.width,
            height: APIinfo.height
        } );
Severity: Major
Found in modules/ve-mw/dm/models/ve.dm.MWImageModel.js and 1 other location - About 4 hrs to fix
modules/ve-mw/dm/models/ve.dm.MWImageModel.js on lines 341..358

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

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

ve.ui.MWGalleryDialog.prototype.insertOrUpdateNode = function () {
    const surfaceModel = this.getFragment().getSurface(),
        surfaceModelDocument = surfaceModel.getDocument(),
        items = this.galleryGroup.items,
        data = [];
Severity: Major
Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js - About 4 hrs to fix

    Function VeUiMWSettingsPage has 114 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    ve.ui.MWSettingsPage = function VeUiMWSettingsPage( name, config ) {
        // Parent constructor
        ve.ui.MWSettingsPage.super.apply( this, arguments );
    
        // Properties
    Severity: Major
    Found in modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js - About 4 hrs to fix

      Function toDomElements has a Cognitive Complexity of 30 (exceeds 5 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: Minor
      Found in modules/ve-mw/dm/nodes/ve.dm.MWBlockImageNode.js - About 4 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 describeChanges has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

      ve.dm.MWImageNode.static.describeChanges = function ( attributeChanges, attributes ) {
          const customKeys = [ 'width', 'height', 'defaultSize', 'src', 'href' ],
              descriptions = [];
      
          function describeSize( width, height ) {
      Severity: Minor
      Found in modules/ve-mw/dm/nodes/ve.dm.MWImageNode.js - About 4 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 renderBody has 110 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ve.ui.MWLanguageVariantNodeContextItem.prototype.renderBody = function () {
          const $body = this.$body,
              $table = $( '<table>' ),
              $header = $( '<tr>' ),
              variantInfo = this.model.getVariantInfo(),

        File ve.init.mw.ArticleTargetLoader.js has 346 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /*!
         * VisualEditor MediaWiki ArticleTargetLoader.
         *
         * @copyright See AUTHORS.txt
         * @license The MIT License (MIT); see LICENSE.txt
        Severity: Minor
        Found in modules/ve-mw/preinit/ve.init.mw.ArticleTargetLoader.js - About 4 hrs to fix

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

                  if ( currentRedirectTargetItem ) {
                      if ( newRedirectData ) {
                          if ( currentRedirectTargetItem.getAttribute( 'title' ) !== newRedirectData ) {
                              // There was a redirect and is a new one, but they differ, so replace
                              this.fragment.replaceMeta(
          Severity: Major
          Found in modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js and 1 other location - About 4 hrs to fix
          modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js on lines 309..331

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

          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

                  if ( currentDisplayTitleItem ) {
                      if ( newDisplayTitle ) {
                          if ( currentDisplayTitleItem.getAttribute( 'content' ) !== newDisplayTitle ) {
                              // There was a display title and is a new one, but they differ, so replace
                              this.fragment.replaceMeta(
          Severity: Major
          Found in modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js and 1 other location - About 4 hrs to fix
          modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js on lines 369..391

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

          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 describeChanges has a Cognitive Complexity of 29 (exceeds 5 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 4 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

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

          ve.ui.MWExtensionDialog.prototype.getTeardownProcess = function ( data ) {
              data = data || {};
              // Parent process
              const process = ve.ui.MWExtensionDialog.super.prototype.getTeardownProcess.call( this, data );
              // Mixin process
          Severity: Major
          Found in modules/ve-mw/ui/dialogs/ve.ui.MWExtensionDialog.js and 4 other locations - About 4 hrs to fix
          modules/ve-mw/ui/dialogs/ve.ui.MWExtensionDialog.js on lines 52..58
          modules/ve-mw/ui/dialogs/ve.ui.MWExtensionDialog.js on lines 63..69
          modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js on lines 53..59
          modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js on lines 78..84

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

          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 5 locations. Consider refactoring.
          Open

          ve.ui.MWExtensionDialog.prototype.getSetupProcess = function ( data ) {
              data = data || {};
              // Parent process
              const process = ve.ui.MWExtensionDialog.super.prototype.getSetupProcess.call( this, data );
              // Mixin process
          Severity: Major
          Found in modules/ve-mw/ui/dialogs/ve.ui.MWExtensionDialog.js and 4 other locations - About 4 hrs to fix
          modules/ve-mw/ui/dialogs/ve.ui.MWExtensionDialog.js on lines 63..69
          modules/ve-mw/ui/dialogs/ve.ui.MWExtensionDialog.js on lines 74..80
          modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js on lines 53..59
          modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js on lines 78..84

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

          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 5 locations. Consider refactoring.
          Open

          ve.ui.MWExtensionInspector.prototype.getTeardownProcess = function ( data ) {
              data = data || {};
              // Parent process
              const process = ve.ui.MWExtensionInspector.super.prototype.getTeardownProcess.call( this, data );
              // Mixin process
          Severity: Major
          Found in modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js and 4 other locations - About 4 hrs to fix
          modules/ve-mw/ui/dialogs/ve.ui.MWExtensionDialog.js on lines 52..58
          modules/ve-mw/ui/dialogs/ve.ui.MWExtensionDialog.js on lines 63..69
          modules/ve-mw/ui/dialogs/ve.ui.MWExtensionDialog.js on lines 74..80
          modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js on lines 53..59

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

          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 5 locations. Consider refactoring.
          Open

          ve.ui.MWExtensionInspector.prototype.getSetupProcess = function ( data ) {
              data = data || {};
              // Parent process
              const process = ve.ui.MWExtensionInspector.super.prototype.getSetupProcess.call( this, data );
              // Mixin process
          Severity: Major
          Found in modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js and 4 other locations - About 4 hrs to fix
          modules/ve-mw/ui/dialogs/ve.ui.MWExtensionDialog.js on lines 52..58
          modules/ve-mw/ui/dialogs/ve.ui.MWExtensionDialog.js on lines 63..69
          modules/ve-mw/ui/dialogs/ve.ui.MWExtensionDialog.js on lines 74..80
          modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js on lines 78..84

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

          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 5 locations. Consider refactoring.
          Open

          ve.ui.MWExtensionDialog.prototype.getReadyProcess = function ( data ) {
              data = data || {};
              // Parent process
              const process = ve.ui.MWExtensionDialog.super.prototype.getReadyProcess.call( this, data );
              // Mixin process
          Severity: Major
          Found in modules/ve-mw/ui/dialogs/ve.ui.MWExtensionDialog.js and 4 other locations - About 4 hrs to fix
          modules/ve-mw/ui/dialogs/ve.ui.MWExtensionDialog.js on lines 52..58
          modules/ve-mw/ui/dialogs/ve.ui.MWExtensionDialog.js on lines 74..80
          modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js on lines 53..59
          modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js on lines 78..84

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

          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 toDataElement has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

          ve.dm.MWGalleryImageNode.static.toDataElement = function ( domElements, converter ) {
              // TODO: Improve handling of missing files. See 'isError' in MWBlockImageNode#toDataElement
              const li = domElements[ 0 ];
              const img = li.querySelector( '.mw-file-element' );
              const imgWrapper = img.parentNode;
          Severity: Minor
          Found in modules/ve-mw/dm/nodes/ve.dm.MWGalleryImageNode.js - About 4 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 getSetupProcess has 101 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          ve.ui.MWGalleryDialog.prototype.getSetupProcess = function ( data ) {
              return ve.ui.MWGalleryDialog.super.prototype.getSetupProcess.call( this, data )
                  .next( () => {
                      const namespaceIds = mw.config.get( 'wgNamespaceIds' ),
                          mwData = this.selectedNode && this.selectedNode.getAttribute( 'mw' ),
          Severity: Major
          Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js - About 4 hrs to fix

            Hooks has 32 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Hooks implements
                TextSlotDiffRendererTablePrefixHook,
                BeforeInitializeHook,
                BeforePageDisplayHook,
                ChangeTagsListActiveHook,
            Severity: Minor
            Found in includes/Hooks.php - About 4 hrs to fix
              Severity
              Category
              Status
              Source
              Language