src/Translator.js

Summary

Maintainability
B
4 hrs
Test Coverage

Function getTranslation has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

Translator.prototype.getTranslation = function(domain, context, key, hasPlural) {
    if(this.domains && this.domains.hasDomain(domain)) {
        var domainTranslations = this.domains.getDomain(domain);
        if(domainTranslations.hasTranslation(key)) {
            var keyTranslations = domainTranslations.getTranslations(key);
Severity: Minor
Found in src/Translator.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

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

Translator.prototype.translate = function() {
    var args = Array.prototype.slice.call(arguments);
    if(args.length > 0) {
        // Check, if placeholder values were passed
        var stringArgsLength = args.length;
Severity: Minor
Found in src/Translator.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

Function dcngettext has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

Translator.prototype.dcngettext = function(domain, context, singularKey, pluralKey, numericValue, placeholderValues) {
Severity: Minor
Found in src/Translator.js - About 45 mins to fix

    Function dngettext has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    Translator.prototype.dngettext = function(domain, singularKey, pluralKey, numericValue, placeholderValues) {
    Severity: Minor
    Found in src/Translator.js - About 35 mins to fix

      Function cngettext has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      Translator.prototype.cngettext = function(context, singularKey, pluralKey, numericValue, placeholderValues) {
      Severity: Minor
      Found in src/Translator.js - About 35 mins to fix

        Function evalPluralFormDefinition has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        Translator.prototype.evalPluralFormDefinition = function(n, pluralFormDefinition) {
            var nplurals, plural;
            try {
                // eslint-disable-next-line no-eval
                eval(pluralFormDefinition);
        Severity: Minor
        Found in src/Translator.js - About 25 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

        There are no issues that match your filters.

        Category
        Status