wikimedia/mediawiki-extensions-VisualEditor

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

Summary

Maintainability
D
2 days
Test Coverage

Function VeUiMWParameterPage has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

ve.ui.MWParameterPage = function VeUiMWParameterPage( parameter, config ) {
    const paramName = parameter.getName();

    // Configuration initialization
    config = ve.extendObject( {
Severity: Major
Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js - About 3 hrs to fix

    Function createValueInput has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    ve.ui.MWParameterPage.prototype.createValueInput = function () {
        const type = this.parameter.getType(),
            value = this.parameter.getValue(),
            valueInputConfig = this.getDefaultInputConfig();
    
    
    Severity: Minor
    Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js - About 3 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 createValueInput has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    ve.ui.MWParameterPage.prototype.createValueInput = function () {
        const type = this.parameter.getType(),
            value = this.parameter.getValue(),
            valueInputConfig = this.getDefaultInputConfig();
    
    
    Severity: Major
    Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js - About 2 hrs to fix

      Function VeUiMWParameterPage has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      ve.ui.MWParameterPage = function VeUiMWParameterPage( parameter, config ) {
          const paramName = parameter.getName();
      
          // Configuration initialization
          config = ve.extendObject( {
      Severity: Minor
      Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js - About 1 hr 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

      Avoid too many return statements within this function.
      Open

              return new ve.ui.MWParameterCheckboxInputWidget( valueInputConfig );
      Severity: Major
      Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return ve.ui.MWExternalLinkAnnotationWidget.static.createExternalLinkInputWidget( valueInputConfig );
        Severity: Major
        Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return new ve.ui.MWLazyMultilineTextInputWidget( valueInputConfig );
          Severity: Major
          Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return new ve.ui.MWLazyMultilineTextInputWidget( ve.extendObject( {
                    rows: 1,
                    autosize: true,
                    allowLinebreaks: false
                }, valueInputConfig ) );
            Severity: Major
            Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return new OO.ui.ComboBoxInputWidget( valueInputConfig );
              Severity: Major
              Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js - About 30 mins to fix

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

                    if ( this.exampleValue ) {
                        $( '<p>' )
                            .addClass( 've-ui-mwParameterPage-doc-example' )
                            .text( ve.msg(
                                'visualeditor-dialog-transclusion-param-example-long',
                Severity: Minor
                Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js and 1 other location - About 40 mins to fix
                modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js on lines 91..96

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

                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 ( this.defaultValue ) {
                        $( '<p>' )
                            .addClass( 've-ui-mwParameterPage-doc-default' )
                            .text( ve.msg( 'visualeditor-dialog-transclusion-param-default', this.defaultValue ) )
                            .appendTo( $doc );
                Severity: Minor
                Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js and 1 other location - About 40 mins to fix
                modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js on lines 98..106

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

                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.ui.MWParameterPage.prototype.focus = function () {
                    this.valueInput.focus();
                };
                Severity: Major
                Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js and 3 other locations - About 35 mins to fix
                modules/ve-mw/ui/inspectors/ve.ui.MWLiveExtensionInspector.js on lines 156..158
                modules/ve-mw/ui/pages/ve.ui.MWCategoriesPage.js on lines 262..264
                modules/ve-mw/ui/widgets/ve.ui.MWCategoryWidget.js on lines 140..142

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

                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

                        return new mw.widgets.UserInputWidget( ve.extendObject( {
                            api: ve.init.target.getContentApi()
                        }, valueInputConfig ) );
                Severity: Minor
                Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js and 1 other location - About 30 mins to fix
                modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js on lines 202..204

                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

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

                        return new mw.widgets.TitleInputWidget( ve.extendObject( {
                            api: ve.init.target.getContentApi()
                        }, valueInputConfig ) );
                Severity: Minor
                Found in modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js and 1 other location - About 30 mins to fix
                modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js on lines 223..225

                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