wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 912 of 912 total issues

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

ve.dm.MWLanguageVariantNode.static.cloneElement = function () {
    // Parent method
    const clone = ve.dm.MWLanguageVariantNode.super.static.cloneElement.apply( this, arguments );
    delete clone.attributes.originalVariantInfo;
    return clone;
Severity: Major
Found in modules/ve-mw/dm/nodes/ve.dm.MWLanguageVariantNode.js and 1 other location - About 2 hrs to fix
modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js on lines 296..301

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

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.MWTransclusionNode.static.cloneElement = function () {
    // Parent method
    const clone = ve.dm.MWTransclusionNode.super.static.cloneElement.apply( this, arguments );
    delete clone.attributes.originalMw;
    return clone;
Severity: Major
Found in modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js and 1 other location - About 2 hrs to fix
modules/ve-mw/dm/nodes/ve.dm.MWLanguageVariantNode.js on lines 260..265

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

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

File init.js has 272 lines of code (exceeds 250 allowed). Consider refactoring.
Open

mw.editcheck = {
    config: require( './config.json' ),
    ecenable: !!( new URL( location.href ).searchParams.get( 'ecenable' ) || window.MWVE_FORCE_EDIT_CHECK_ENABLED )
};

Severity: Minor
Found in editcheck/modules/init.js - About 2 hrs to fix

    Function changeImageSource has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    ve.dm.MWImageModel.prototype.changeImageSource = function ( attrs, APIinfo ) {
        this.changedImageSource = true;
    
        if ( attrs.mediaType ) {
            this.setMediaType( attrs.mediaType );
    Severity: Major
    Found in modules/ve-mw/dm/models/ve.dm.MWImageModel.js - About 2 hrs to fix

      Function VeCeMWGalleryImageNode has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ve.ce.MWGalleryImageNode = function VeCeMWGalleryImageNode( model ) {
          // Parent constructor
          ve.ce.MWGalleryImageNode.super.apply( this, arguments );
      
          // DOM hierarchy for MWGalleryImageNode:
      Severity: Major
      Found in modules/ve-mw/ce/nodes/ve.ce.MWGalleryImageNode.js - About 2 hrs to fix

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

                    $header
                        .append( $( '<th>' ).text(
                            ve.msg( 'visualeditor-mwlanguagevariantcontextitem-rule-name-label' )
                        ) )
                        .append( $( '<th>' ).text(
        modules/ve-mw/ui/contextitems/ve.ui.MWLanguageVariantNodeContextItem.js on lines 120..129

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

        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.MWLiveExtensionInspector = function VeUiMWLiveExtensionInspector() {
            // Parent constructor
            ve.ui.MWLiveExtensionInspector.super.apply( this, arguments );
        
            this.updatePreviewDebounced = ve.debounce( this.updatePreview.bind( this ), 1000 );
        modules/ve-mw/ui/dialogs/ve.ui.MWExtensionPreviewDialog.js on lines 18..23

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

        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.MWExtensionPreviewDialog = function VeUiMWExtensionPreviewDialog() {
            // Parent constructor
            ve.ui.MWExtensionPreviewDialog.super.apply( this, arguments );
        
            this.updatePreviewDebounced = ve.debounce( this.updatePreview.bind( this ), 1000 );
        Severity: Major
        Found in modules/ve-mw/ui/dialogs/ve.ui.MWExtensionPreviewDialog.js and 1 other location - About 2 hrs to fix
        modules/ve-mw/ui/inspectors/ve.ui.MWLiveExtensionInspector.js on lines 18..23

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

        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

                    $header
                        .append( $( '<th>' ).text(
                            ve.msg( 'visualeditor-mwlanguagevariantcontextitem-rule-name-label' )
                        ) )
                        .append( $( '<th>' ).text(
        modules/ve-mw/ui/contextitems/ve.ui.MWLanguageVariantNodeContextItem.js on lines 154..163

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

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

        ve.ui.MWWikitextLinkAnnotationInspector.prototype.getTeardownProcess = function ( data ) {
            data = data || {};
            // Call grand-parent
            return ve.ui.FragmentInspector.prototype.getTeardownProcess.call( this, data )
                .first( () => {

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

          ve.dm.MWNoContentConvertMetaItem.static.toDomElements = function ( dataElement, doc ) {
              const meta = doc.createElement( 'meta' );
              meta.setAttribute(
                  'property',
                  ( dataElement.attributes && dataElement.attributes.originalProperty ) || 'mw:PageProp/nocontentconvert'
          modules/ve-mw/dm/metaitems/ve.dm.MWNoTitleConvertMetaItem.js on lines 43..50

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

          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.MWNoTitleConvertMetaItem.static.toDomElements = function ( dataElement, doc ) {
              const meta = doc.createElement( 'meta' );
              meta.setAttribute(
                  'property',
                  ( dataElement.attributes && dataElement.attributes.originalProperty ) || 'mw:PageProp/notitleconvert'
          Severity: Major
          Found in modules/ve-mw/dm/metaitems/ve.dm.MWNoTitleConvertMetaItem.js and 1 other location - About 2 hrs to fix
          modules/ve-mw/dm/metaitems/ve.dm.MWNoContentConvertMetaItem.js on lines 43..50

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

          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 ( mw.config.get( 'wgVariantArticlePath' ) ) {
                  this.metaItemCheckboxes.push(
                      {
                          metaName: 'mwNoContentConvert',
                          label: ve.msg( 'visualeditor-dialog-meta-settings-nocontentconvert-label' ),
          Severity: Major
          Found in modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js and 1 other location - About 2 hrs to fix
          modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js on lines 113..126

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

          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.MWLanguageMetaItem.static.toDomElements = function ( dataElement, doc ) {
              const domElement = doc.createElement( 'link' );
              domElement.setAttribute( 'rel', 'mw:PageProp/Language' );
              domElement.setAttribute( 'href', dataElement.attributes.href );
              return [ domElement ];
          Severity: Major
          Found in modules/ve-mw/dm/metaitems/ve.dm.MWLanguageMetaItem.js and 1 other location - About 2 hrs to fix
          modules/ve-mw/dm/metaitems/ve.dm.MWDisplayTitleMetaItem.js on lines 45..50

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

          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 ( mw.config.get( 'wgNamespaceNumber' ) === mw.config.get( 'wgNamespaceIds' ).category ) {
                  this.metaItemCheckboxes.push(
                      {
                          metaName: 'mwHiddenCategory',
                          label: ve.msg( 'visualeditor-dialog-meta-settings-hiddencat-label' ),
          Severity: Major
          Found in modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js and 1 other location - About 2 hrs to fix
          modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js on lines 104..117

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

          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.MWDisplayTitleMetaItem.static.toDomElements = function ( dataElement, doc ) {
              const meta = doc.createElement( 'meta' );
              meta.setAttribute( 'property', 'mw:PageProp/displaytitle' );
              meta.setAttribute( 'content', dataElement.attributes.content );
              return [ meta ];
          Severity: Major
          Found in modules/ve-mw/dm/metaitems/ve.dm.MWDisplayTitleMetaItem.js and 1 other location - About 2 hrs to fix
          modules/ve-mw/dm/metaitems/ve.dm.MWLanguageMetaItem.js on lines 43..48

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

          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

          Method onGetPreferences has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function onGetPreferences( $user, &$preferences ) {
                  $services = MediaWikiServices::getInstance();
                  $userOptionsLookup = $services->getUserOptionsLookup();
                  $veConfig = $services->getConfigFactory()->makeConfig( 'visualeditor' );
                  $isBeta = $veConfig->get( 'VisualEditorEnableBetaFeature' );
          Severity: Major
          Found in includes/Hooks.php - About 2 hrs to fix

            File ve.ui.MWSettingsPage.js has 268 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /*!
             * VisualEditor user interface MWSettingsPage class.
             *
             * @copyright See AUTHORS.txt
             * @license The MIT License (MIT); see LICENSE.txt
            Severity: Minor
            Found in modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js - About 2 hrs to fix

              Function save has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

              ve.init.mw.ArticleTarget.prototype.save = function ( doc, options ) {
                  // Prevent duplicate requests
                  if ( this.saving ) {
                      return this.saving;
                  }
              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 teardown has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

              ve.ui.MWCategoriesPage.prototype.teardown = function ( data ) {
                  const currentDefaultSortKeyItem = this.getDefaultSortKeyItem(),
                      newDefaultSortKey = this.defaultSortInput.getValue();
              
                  if ( data && data.action === 'done' ) {
              Severity: Minor
              Found in modules/ve-mw/ui/pages/ve.ui.MWCategoriesPage.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

              Severity
              Category
              Status
              Source
              Language