wikimedia/mediawiki-core

View on GitHub
resources/lib/jquery.i18n/src/jquery.i18n.parser.js

Summary

Maintainability
F
3 days
Test Coverage

Function ast has 164 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        ast: function ( message ) {
            var pipe, colon, backslash, anyCharacter, dollar, digits, regularLiteral,
                regularLiteralWithoutBar, regularLiteralWithoutSpace, escapedOrLiteralWithoutBar,
                escapedOrRegularLiteral, templateContents, templateName, openTemplate,
                closeTemplate, expression, paramExpression, result,
Severity: Major
Found in resources/lib/jquery.i18n/src/jquery.i18n.parser.js - About 6 hrs to fix

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

                function sequence( parserSyntax ) {
                    var i, res,
                        originalPos = pos,
                        result = [];
    
    
    Severity: Major
    Found in resources/lib/jquery.i18n/src/jquery.i18n.parser.js and 1 other location - About 3 hrs to fix
    resources/lib/CLDRPluralRuleParser/CLDRPluralRuleParser.js on lines 127..145

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

    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

                function nOrMore( n, p ) {
                    return function () {
                        var originalPos = pos,
                            result = [],
                            parsed = p();
    Severity: Major
    Found in resources/lib/jquery.i18n/src/jquery.i18n.parser.js and 1 other location - About 3 hrs to fix
    resources/lib/CLDRPluralRuleParser/CLDRPluralRuleParser.js on lines 149..168

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

    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

                function choice( parserSyntax ) {
                    return function () {
                        var i, result;
    
                        for ( i = 0; i < parserSyntax.length; i++ ) {
    Severity: Major
    Found in resources/lib/jquery.i18n/src/jquery.i18n.parser.js and 1 other location - About 2 hrs to fix
    resources/lib/CLDRPluralRuleParser/CLDRPluralRuleParser.js on lines 108..122

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

    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

                function makeRegexParser( regex ) {
                    return function () {
                        var matches = message.slice( pos ).match( regex );
    
                        if ( matches === null ) {
    Severity: Major
    Found in resources/lib/jquery.i18n/src/jquery.i18n.parser.js and 2 other locations - About 1 hr to fix
    resources/lib/CLDRPluralRuleParser/CLDRPluralRuleParser.js on lines 186..198
    resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js on lines 458..467

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

    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

                function makeStringParser( s ) {
                    var len = s.length;
    
                    return function () {
                        var result = null;
    Severity: Major
    Found in resources/lib/jquery.i18n/src/jquery.i18n.parser.js and 1 other location - About 1 hr to fix
    resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js on lines 437..447

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

    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

            simpleParse: function ( message, parameters ) {
                return message.replace( /\$(\d+)/g, function ( str, match ) {
                    var index = parseInt( match, 10 ) - 1;
    
                    return parameters[ index ] !== undefined ? parameters[ index ] : '$' + match;
    Severity: Major
    Found in resources/lib/jquery.i18n/src/jquery.i18n.parser.js and 1 other location - About 1 hr to fix
    resources/lib/jquery.i18n/src/jquery.i18n.js on lines 265..270

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

    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

                var pipe, colon, backslash, anyCharacter, dollar, digits, regularLiteral,
                    regularLiteralWithoutBar, regularLiteralWithoutSpace, escapedOrLiteralWithoutBar,
                    escapedOrRegularLiteral, templateContents, templateName, openTemplate,
                    closeTemplate, expression, paramExpression, result,
                    pos = 0;
    Severity: Major
    Found in resources/lib/jquery.i18n/src/jquery.i18n.parser.js and 1 other location - About 1 hr to fix
    resources/src/mediawiki.page.gallery.js on lines 82..100

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

    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

                    function () {
                        var res = sequence( [ templateName, nOrMore( 0, templateParam ) ] );
    
                        if ( res === null ) {
                            return null;
    Severity: Major
    Found in resources/lib/jquery.i18n/src/jquery.i18n.parser.js and 1 other location - About 1 hr to fix
    resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js on lines 639..648

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

    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

                function replacement() {
                    var result = sequence( [ dollar, digits ] );
    
                    if ( result === null ) {
                        return null;
    Severity: Major
    Found in resources/lib/jquery.i18n/src/jquery.i18n.parser.js and 1 other location - About 1 hr to fix
    resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js on lines 534..543

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

    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.emitter.language = $.i18n.languages[ $.i18n().locale ] ||
                    $.i18n.languages[ 'default' ];
    Severity: Minor
    Found in resources/lib/jquery.i18n/src/jquery.i18n.parser.js and 1 other location - About 55 mins to fix
    resources/lib/jquery.i18n/src/jquery.i18n.js on lines 168..168

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

    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 ( result === null || pos !== message.length ) {
                    throw new Error( 'Parse error at position ' + pos.toString() + ' in input: ' + message );
                }
    Severity: Minor
    Found in resources/lib/jquery.i18n/src/jquery.i18n.parser.js and 1 other location - About 50 mins to fix
    resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js on lines 906..908

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

    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

                function templateWithReplacement() {
                    var result = sequence( [ templateName, colon, replacement ] );
    
                    return result === null ? null : [ result[ 0 ], result[ 2 ] ];
                }
    Severity: Major
    Found in resources/lib/jquery.i18n/src/jquery.i18n.parser.js and 3 other locations - About 35 mins to fix
    resources/lib/jquery.i18n/src/jquery.i18n.parser.js on lines 240..244
    resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js on lines 605..612
    resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js on lines 613..620

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

    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

                function templateWithOutReplacement() {
                    var result = sequence( [ templateName, colon, paramExpression ] );
    
                    return result === null ? null : [ result[ 0 ], result[ 2 ] ];
                }
    Severity: Major
    Found in resources/lib/jquery.i18n/src/jquery.i18n.parser.js and 3 other locations - About 35 mins to fix
    resources/lib/jquery.i18n/src/jquery.i18n.parser.js on lines 234..238
    resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js on lines 605..612
    resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js on lines 613..620

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

    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

                function start() {
                    var result = nOrMore( 0, expression )();
    
                    if ( result === null ) {
                        return null;
    Severity: Minor
    Found in resources/lib/jquery.i18n/src/jquery.i18n.parser.js and 1 other location - About 35 mins to fix
    resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js on lines 888..894

    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

    There are no issues that match your filters.

    Category
    Status