wikimedia/mediawiki-extensions-VisualEditor

View on GitHub
modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js

Summary

Maintainability
F
6 days
Test Coverage

Function teardown has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWAdvancedSettingsPage.prototype.teardown = function ( data ) {
    // Data initialization
    data = data || {};
    if ( data.action !== 'done' ) {
        return;
Severity: Minor
Found in modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js - About 5 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 VeUiMWAdvancedSettingsPage has 97 lines of code (exceeds 25 allowed). Consider refactoring.
Open

ve.ui.MWAdvancedSettingsPage = function VeUiMWAdvancedSettingsPage( name, config ) {
    // Parent constructor
    ve.ui.MWAdvancedSettingsPage.super.apply( this, arguments );

    // Properties
Severity: Major
Found in modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js - About 3 hrs to fix

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

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

      Function setup has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ve.ui.MWAdvancedSettingsPage.prototype.setup = function ( fragment, config ) {
          this.fragment = fragment;
      
          // Indexing items
          const indexingField = this.indexing.getField();
      Severity: Minor
      Found in modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js - About 1 hr to fix

        Function setup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        ve.ui.MWAdvancedSettingsPage.prototype.setup = function ( fragment, config ) {
            this.fragment = fragment;
        
            // Indexing items
            const indexingField = this.indexing.getField();
        Severity: Minor
        Found in modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js - About 35 mins 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 3 locations. Consider refactoring.
        Open

            if ( this.indexingOptionTouched ) {
                if ( newIndexingData.data === 'default' ) {
                    if ( currentIndexingItem ) {
                        this.fragment.removeMeta( currentIndexingItem );
                    }
        Severity: Major
        Found in modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js and 2 other locations - About 6 hrs to fix
        modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js on lines 280..297
        modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js on lines 348..365

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

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

            if ( this.newSectionEditLinkOptionTouched ) {
                if ( newNewSectionEditLinkData.data === 'default' ) {
                    if ( currentNewSectionEditLinkItem ) {
                        this.fragment.removeMeta( currentNewSectionEditLinkItem );
                    }
        Severity: Major
        Found in modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js and 2 other locations - About 6 hrs to fix
        modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js on lines 256..273
        modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js on lines 348..365

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

        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

                new OO.ui.ButtonSelectWidget()
                    .addItems( [
                        new OO.ui.ButtonOptionWidget( {
                            data: 'mw:PageProp/index',
                            label: ve.msg( 'visualeditor-dialog-meta-settings-index-force' )
        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.MWAdvancedSettingsPage.js on lines 63..78

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

        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

                new OO.ui.ButtonSelectWidget()
                    .addItems( [
                        new OO.ui.ButtonOptionWidget( {
                            data: 'mw:PageProp/newsectionlink',
                            label: ve.msg( 'visualeditor-dialog-meta-settings-newsectioneditlink-force' )
        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.MWAdvancedSettingsPage.js on lines 37..52

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

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

        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

        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

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

            this.metaItemCheckboxes.forEach( ( metaItemCheckbox ) => {
                const isSelected = !!this.getMetaItem( metaItemCheckbox.metaName );
                metaItemCheckbox.fieldLayout.getField()
                    .setSelected( isSelected )
                    .setDisabled( config.isReadOnly );
        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 313..318

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

        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.displayTitleField = new OO.ui.FieldLayout(
                this.displayTitleInput,
                {
                    $overlay: config.$overlay,
                    align: 'top',
        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.MWCategoriesPage.js on lines 59..67

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

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

            this.advancedSettingsFieldset = new OO.ui.FieldsetLayout( {
                label: ve.msg( 'visualeditor-dialog-meta-advancedsettings-label' ),
                icon: 'settings'
            } );
        Severity: Minor
        Found in modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js and 1 other location - About 30 mins to fix
        modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js on lines 30..33

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

        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

        There are no issues that match your filters.

        Category
        Status