i18next/i18next

View on GitHub

Showing 101 of 101 total issues

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 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 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 prepareLoading has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  prepareLoading(languages, namespaces, options = {}, callback) {
    if (!this.backend) {
      this.logger.warn('No backend was added via i18next.use. Will not load resources.');
      return callback && callback();
    }
Severity: Minor
Found in src/BackendConnector.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

Avoid too many return statements within this function.
Open

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

    Avoid too many return statements within this function.
    Open

            if (typeof mix === 'string') return mix;
    Severity: Major
    Found in src/ResourceStore.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              if (p && typeof mix[p] === 'string') return mix[p];
      Severity: Major
      Found in src/ResourceStore.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

              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 resolved;
            Severity: Major
            Found in src/Translator.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

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

                Avoid too many return statements within this function.
                Open

                      return returnSuffix();
                Severity: Major
                Found in src/PluralResolver.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      if (this.hasResourceBundle(lng, ns)) return true;
                  Severity: Major
                  Found in src/i18next.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
                    Severity: Major
                    Found in src/i18next.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

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

                        Avoid too many return statements within this function.
                        Open

                              if (mix === undefined) return undefined;
                        Severity: Major
                        Found in src/ResourceStore.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 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

                                    if (joinedPath) return deepFind(mix, joinedPath, keySeparator);
                              Severity: Major
                              Found in src/ResourceStore.js - About 30 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language