wikimedia/mediawiki-extensions-UploadWizard

View on GitHub
resources/details/uw.TitleDetailsWidget.js

Summary

Maintainability
C
1 day
Test Coverage

Function processDestinationCheck has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    uw.TitleDetailsWidget.prototype.processDestinationCheck = function ( result ) {
        var messageKey, messageParams, errors, titleString;

        if ( result.unique.isUnique && result.blacklist.notBlacklisted && !result.unique.isProtected ) {
            return [];
Severity: Major
Found in resources/details/uw.TitleDetailsWidget.js - About 2 hrs to fix

    Function validateTitleInput has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        uw.TitleDetailsWidget.prototype.validateTitleInput = function ( value ) {
            var
                errors = [],
                processDestinationCheck = this.processDestinationCheck,
                title = this.buildTitleFromInput( value ),
    Severity: Minor
    Found in resources/details/uw.TitleDetailsWidget.js - About 1 hr to fix

      Avoid too many return statements within this function.
      Open

              return mw.DestinationChecker.checkTitle( title.getPrefixedText() )
                  .then( ( result ) => {
                      var moreErrors = processDestinationCheck( result );
                      if ( result.blacklist.unavailable ) {
                          // We don't have a title blacklist, so just check for some likely undesirable patterns.
      Severity: Major
      Found in resources/details/uw.TitleDetailsWidget.js - About 30 mins to fix

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

                if ( this.config.maxLength && length > this.config.maxLength ) {
                    errors.push( mw.message( 'mwe-upwiz-error-title-too-long', this.config.maxLength ) );
                    return $.Deferred().resolve( errors ).promise();
                }
        Severity: Major
        Found in resources/details/uw.TitleDetailsWidget.js and 1 other location - About 2 hrs to fix
        resources/details/uw.TitleDetailsWidget.js on lines 118..121

        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 ( this.config.minLength && length < this.config.minLength ) {
                    errors.push( mw.message( 'mwe-upwiz-error-title-too-short', this.config.minLength ) );
                    return $.Deferred().resolve( errors ).promise();
                }
        Severity: Major
        Found in resources/details/uw.TitleDetailsWidget.js and 1 other location - About 2 hrs to fix
        resources/details/uw.TitleDetailsWidget.js on lines 123..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 4 locations. Consider refactoring.
        Open

            uw.TitleDetailsWidget.prototype.getWikiText = function () {
                return this.titleInput.getValue().trim();
            };
        Severity: Major
        Found in resources/details/uw.TitleDetailsWidget.js and 3 other locations - About 40 mins to fix
        resources/details/uw.DateDetailsWidget.js on lines 188..190
        resources/details/uw.OtherDetailsWidget.js on lines 31..33
        resources/details/uw.SingleLanguageInputWidget.js on lines 192..194

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

        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 ( value === '' ) {
                    errors.push( mw.message( 'mwe-upwiz-error-title-blank' ) );
                    return $.Deferred().resolve( errors ).promise();
                }
        Severity: Minor
        Found in resources/details/uw.TitleDetailsWidget.js and 1 other location - About 40 mins to fix
        resources/details/uw.TitleDetailsWidget.js on lines 128..131

        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 ( !title ) {
                    errors.push( mw.message( 'mwe-upwiz-error-title-invalid' ) );
                    return $.Deferred().resolve( errors ).promise();
                }
        Severity: Minor
        Found in resources/details/uw.TitleDetailsWidget.js and 1 other location - About 40 mins to fix
        resources/details/uw.TitleDetailsWidget.js on lines 113..116

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

            uw.TitleDetailsWidget.prototype.getSerialized = function () {
                return {
                    title: this.titleInput.getValue()
                };
            };
        Severity: Minor
        Found in resources/details/uw.TitleDetailsWidget.js and 2 other locations - About 40 mins to fix
        resources/details/uw.CampaignDetailsWidget.js on lines 73..77
        resources/details/uw.OtherDetailsWidget.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 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

        There are no issues that match your filters.

        Category
        Status