i18next/i18next

View on GitHub

Showing 71 of 71 total issues

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

  11: function(n) {return Number((n==1 || n==11) ? 0 : (n==2 || n==12) ? 1 : (n > 2 && n < 20) ? 2 : 3);},
Severity: Minor
Found in src/PluralResolver.js - About 45 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

Function format has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  format(value, format, lng, options = {}) {
    const formats = format.split(this.formatSeparator);

    const result = formats.reduce((mem, f) => {
      const { formatName, formatOptions } = parseFormatStr(f);
Severity: Minor
Found in src/Formatter.js - About 45 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

Avoid deeply nested control flow statements.
Open

              if (
                needsZeroSuffixLookup &&
                options[`defaultValue${this.options.pluralSeparator}zero`] &&
                suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0
              ) {
Severity: Major
Found in src/Translator.js - About 45 mins to fix

    Function 19 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      19: function(n) {return Number(n==1 ? 0 : n==0 || ( n%100>1 && n%100<11) ? 1 : (n%100>10 && n%100<20 ) ? 2 : 3);},
    Severity: Minor
    Found in src/PluralResolver.js - About 45 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

    Function setResolvedLanguage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      setResolvedLanguage(l) {
        if (!l || !this.languages) return;
        if (['cimode', 'dev'].indexOf(l) > -1) return;
        for (let li = 0; li < this.languages.length; li++) {
          const lngInLngs = this.languages[li];
    Severity: Minor
    Found in src/i18next.js - About 45 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

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

      handle(processors, value, key, options, translator) {
    Severity: Minor
    Found in src/postProcessor.js - About 35 mins to fix

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

        data,
        defaultData,
        key,
        keySeparator = '.',
        ignoreJSONStructure = true,
      Severity: Minor
      Found in src/Interpolator.js - About 35 mins to fix

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

          21: function(n) {return Number(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n%100==4 ? 3 : 0); },
        Severity: Minor
        Found in src/PluralResolver.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

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

        export function looksLikeObjectPath(key, nsSeparator, keySeparator) {
          nsSeparator = nsSeparator || '';
          keySeparator = keySeparator || '';
          const possibleChars = chars.filter(
            (c) => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0,
        Severity: Minor
        Found in src/utils.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

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

          22: function(n) {return Number(n==1 ? 0 : n==2 ? 1 : (n<0 || n>10) && n%10==0 ? 2 : 3); }
        Severity: Minor
        Found in src/PluralResolver.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

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

          8: function(n) {return Number((n==1) ? 0 : (n==2) ? 1 : (n != 8 && n != 11) ? 2 : 3);},
        Severity: Minor
        Found in src/PluralResolver.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

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

          dir(lng) {
            if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
            if (!lng) return 'rtl';
        
            const rtlLngs = [
        Severity: Minor
        Found in src/i18next.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

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

          getRule(code, options = {}) {
            if (this.shouldUseIntlApi()) {
              try {
                return new Intl.PluralRules(getCleanedCode(code === 'dev' ? 'en' : code), { type: options.ordinal ? 'ordinal' : 'cardinal' });
              } catch (err) {
        Severity: Minor
        Found in src/PluralResolver.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

        Avoid too many return statements within this function.
        Open

            return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
        Severity: Major
        Found in src/PluralResolver.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return res;
          Severity: Major
          Found in src/Translator.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return resolved;
            Severity: Major
            Found in src/Translator.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                        return resolved;
              Severity: Major
              Found in src/Translator.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    if (!this.services.backendConnector.backend || (this.options.resources && !this.options.partialBundledLanguages)) return true;
                Severity: Major
                Found in src/i18next.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return false;
                  Severity: Major
                  Found in src/i18next.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return r;
                    Severity: Major
                    Found in src/Translator.js - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language