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.ui.MWAdvancedSettingsPage.prototype.getMetaItem = function ( name ) {
    return this.fragment.getDocument().getMetaList().getItemsInGroup( name )[ 0 ] || null;
};
Severity: Major
Found in modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js and 1 other location - About 1 hr to fix
modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js on lines 271..273

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

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.MWParameterModel.prototype.setValue = function ( value ) {
    if ( this.value !== value ) {
        this.value = value;
        this.emit( 'change' );
    }
Severity: Major
Found in modules/ve-mw/dm/models/ve.dm.MWParameterModel.js and 1 other location - About 1 hr to fix
modules/ve-mw/dm/models/ve.dm.MWTransclusionContentModel.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 65.

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.MWTransclusionContentModel.prototype.setWikitext = function ( wikitext ) {
    if ( this.wikitext !== wikitext ) {
        this.wikitext = wikitext;
        this.emit( 'change' );
    }
Severity: Major
Found in modules/ve-mw/dm/models/ve.dm.MWTransclusionContentModel.js and 1 other location - About 1 hr to fix
modules/ve-mw/dm/models/ve.dm.MWParameterModel.js on lines 159..164

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

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.MWSettingsPage.prototype.getMetaItem = function ( name ) {
    return this.fragment.getDocument().getMetaList().getItemsInGroup( name )[ 0 ] || null;
};
Severity: Major
Found in modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js and 1 other location - About 1 hr to fix
modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js on lines 174..176

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

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

ve.ui.MWLanguagesPage.prototype.onLoadLanguageData = function ( languages ) {
    const $languagesTable = $( '<table>' ),
        languageslength = languages.length;

    $languagesTable
Severity: Minor
Found in modules/ve-mw/ui/pages/ve.ui.MWLanguagesPage.js - About 1 hr to fix

    Function setupEditLinks has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            setupEditLinks: function () {
                // NWE
                if ( init.isWikitextAvailable && !isOnlyTabVE() ) {
                    $(
                        // Edit section links, except VE ones when both editors visible
    Severity: Minor
    Found in modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js - About 1 hr to fix

      Method saveWikitext has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function saveWikitext( Title $title, $wikitext, $params ) {
              $apiParams = [
                  'action' => 'edit',
                  'title' => $title->getPrefixedDBkey(),
                  'text' => $wikitext,
      Severity: Minor
      Found in includes/ApiVisualEditorEdit.php - About 1 hr to fix

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

        ve.dm.MWStaticRedirectMetaItem.static.toDomElements = function ( dataElement, doc ) {
            const meta = doc.createElement( 'meta' );
            meta.setAttribute( 'property', 'mw:PageProp/staticredirect' );
            return [ meta ];
        };
        modules/ve-mw/dm/metaitems/ve.dm.MWHiddenCategoryMetaItem.js on lines 39..43
        modules/ve-mw/dm/metaitems/ve.dm.MWNoEditSectionMetaItem.js on lines 35..39
        modules/ve-mw/dm/metaitems/ve.dm.MWNoGalleryMetaItem.js on lines 39..43

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

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

        ve.dm.MWHiddenCategoryMetaItem.static.toDomElements = function ( dataElement, doc ) {
            const meta = doc.createElement( 'meta' );
            meta.setAttribute( 'property', 'mw:PageProp/hiddencat' );
            return [ meta ];
        };
        modules/ve-mw/dm/metaitems/ve.dm.MWNoEditSectionMetaItem.js on lines 35..39
        modules/ve-mw/dm/metaitems/ve.dm.MWNoGalleryMetaItem.js on lines 39..43
        modules/ve-mw/dm/metaitems/ve.dm.MWStaticRedirectMetaItem.js on lines 39..43

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

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

        ve.dm.MWNoGalleryMetaItem.static.toDomElements = function ( dataElement, doc ) {
            const meta = doc.createElement( 'meta' );
            meta.setAttribute( 'property', 'mw:PageProp/nogallery' );
            return [ meta ];
        };
        Severity: Major
        Found in modules/ve-mw/dm/metaitems/ve.dm.MWNoGalleryMetaItem.js and 3 other locations - About 1 hr to fix
        modules/ve-mw/dm/metaitems/ve.dm.MWHiddenCategoryMetaItem.js on lines 39..43
        modules/ve-mw/dm/metaitems/ve.dm.MWNoEditSectionMetaItem.js on lines 35..39
        modules/ve-mw/dm/metaitems/ve.dm.MWStaticRedirectMetaItem.js on lines 39..43

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

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

        ve.dm.MWNoEditSectionMetaItem.static.toDomElements = function ( dataElement, doc ) {
            const meta = doc.createElement( 'meta' );
            meta.setAttribute( 'property', 'mw:PageProp/noeditsection' );
            return [ meta ];
        };
        modules/ve-mw/dm/metaitems/ve.dm.MWHiddenCategoryMetaItem.js on lines 39..43
        modules/ve-mw/dm/metaitems/ve.dm.MWNoGalleryMetaItem.js on lines 39..43
        modules/ve-mw/dm/metaitems/ve.dm.MWStaticRedirectMetaItem.js on lines 39..43

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

        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.MWTemplatesUsedPage.prototype.setupOutlineItem = function () {
            this.outlineItem
                .setIcon( 'puzzle' )
                .setLabel( ve.msg( 'visualeditor-templatesused-tool' ) );
        };
        Severity: Major
        Found in modules/ve-mw/ui/pages/ve.ui.MWTemplatesUsedPage.js and 1 other location - About 1 hr to fix
        modules/ve-mw/ui/pages/ve.ui.MWCategoriesPage.js on lines 93..97

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

        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 ( metaItem instanceof ve.dm.MWTOCMetaItem ) {
                const property = metaItem.getAttribute( 'property' );
                if ( property === 'mw:PageProp/forcetoc' ) {
                    this.mwTOCForce = false;
                } else if ( property === 'mw:PageProp/notoc' ) {
        Severity: Major
        Found in modules/ve-mw/ui/widgets/ve.ui.MWTocWidget.js and 1 other location - About 1 hr to fix
        modules/ve-mw/ui/widgets/ve.ui.MWTocWidget.js on lines 67..74

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

        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 ( metaItem instanceof ve.dm.MWTOCMetaItem ) {
                const property = metaItem.getAttribute( 'property' );
                if ( property === 'mw:PageProp/forcetoc' ) {
                    this.mwTOCForce = true;
                } else if ( property === 'mw:PageProp/notoc' ) {
        Severity: Major
        Found in modules/ve-mw/ui/widgets/ve.ui.MWTocWidget.js and 1 other location - About 1 hr to fix
        modules/ve-mw/ui/widgets/ve.ui.MWTocWidget.js on lines 84..91

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

        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.MWCategoriesPage.prototype.setupOutlineItem = function () {
            this.outlineItem
                .setIcon( 'tag' )
                .setLabel( ve.msg( 'visualeditor-dialog-meta-categories-section' ) );
        };
        Severity: Major
        Found in modules/ve-mw/ui/pages/ve.ui.MWCategoriesPage.js and 1 other location - About 1 hr to fix
        modules/ve-mw/ui/pages/ve.ui.MWTemplatesUsedPage.js on lines 71..75

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

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

        ve.ui.MWHelpListToolGroup.prototype.setActive = function () {
            // Parent method
            ve.ui.MWHelpListToolGroup.super.prototype.setActive.apply( this, arguments );
        
            if ( this.active && !this.versionPromise ) {
        Severity: Minor
        Found in modules/ve-mw/ui/toolgroups/ve.ui.MWHelpListToolGroup.js - About 1 hr to fix

          Function loadSuccess has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          ve.init.mw.ArticleTarget.prototype.loadSuccess = function ( response ) {
              const data = response ? ( response.visualeditor || response.visualeditoredit ) : null;
          
              if ( !data || typeof data.content !== 'string' ) {
                  this.loadFail( 've-api', { errors: [ {
          Severity: Minor
          Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 1 hr to fix

            Function getSetupProcess has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            ve.ui.MWMetaDialog.prototype.getSetupProcess = function ( data ) {
                data = data || {};
                return ve.ui.MWMetaDialog.super.prototype.getSetupProcess.call( this, data )
                    .next( () => {
                        const surfaceModel = this.getFragment().getSurface(),
            Severity: Minor
            Found in modules/ve-mw/ui/dialogs/ve.ui.MWMetaDialog.js - About 1 hr to fix

              Function onDocumentKeyDown has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.onDocumentKeyDown = function ( e ) {
                  let item;
              
                  switch ( e.keyCode ) {
                      case OO.ui.Keys.HOME:

                Function fixFragmentLinks has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                mw.libs.ve.fixFragmentLinks = function ( container, docTitle, prefix ) {
                    const docTitleText = docTitle.getPrefixedText();
                    prefix = prefix || '';
                    Array.prototype.forEach.call( container.querySelectorAll( 'a[href*="#"]' ), ( el ) => {
                        let fragment = null;
                Severity: Minor
                Found in modules/ve-mw/preinit/ve.utils.parsoid.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language