i18next/i18next

View on GitHub

Showing 71 of 71 total issues

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

          return key;
    Severity: Major
    Found in src/Translator.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 returnSuffix();
        Severity: Major
        Found in src/PluralResolver.js - About 30 mins to fix

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

            getSuffix(code, count, options = {}) {
              const rule = this.getRule(code, options);
          
              if (rule) {
                if (this.shouldUseIntlApi()) {
          Severity: Minor
          Found in src/PluralResolver.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

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

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

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

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

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

            getUsedParamsDetails(options = {}) {
              // we need to remember to extend this array whenever new option properties are added
              const optionsKeys = [
                'defaultValue',
                'ordinal',
          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

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

            addResource(lng, ns, key, value, options = { silent: false }) {
              const keySeparator =
                options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
          
              let path = [lng, ns];
          Severity: Minor
          Found in src/ResourceStore.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

          Function prepareLoading has a Cognitive Complexity of 6 (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 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

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

          export function setPath(object, path, newValue) {
            const { obj, k } = getLastOfPath(object, path, Object);
            if (obj !== undefined || path.length === 1) {
              obj[k] = newValue;
              return;
          Severity: Minor
          Found in src/utils.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

          Severity
          Category
          Status
          Source
          Language