Function init
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
init(options = {}, callback) {
this.isInitializing = true;
if (typeof options === 'function') {
callback = options;
options = {};
- Read upRead up
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
File i18next.js
has 522 lines of code (exceeds 300 allowed). Consider refactoring. Open
import baseLogger from './logger.js';
import EventEmitter from './EventEmitter.js';
import ResourceStore from './ResourceStore.js';
import Translator from './Translator.js';
import LanguageUtils from './LanguageUtils.js';
Function changeLanguage
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
changeLanguage(lng, callback) {
this.isLanguageChangingTo = lng;
const deferred = defer();
this.emit('languageChanging', lng);
- Read upRead up
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 init
has 135 lines of code (exceeds 70 allowed). Consider refactoring. Open
init(options = {}, callback) {
this.isInitializing = true;
if (typeof options === 'function') {
callback = options;
options = {};
Function loadResources
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
loadResources(language, callback = noop) {
let usedCallback = callback;
const usedLng = typeof language === 'string' ? language : this.language;
if (typeof language === 'function') usedCallback = language;
- Read upRead up
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 getFixedT
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
getFixedT(lng, ns, keyPrefix) {
const fixedT = (key, opts, ...rest) => {
let options;
if (typeof opts !== 'object') {
options = this.options.overloadTranslationOptionHandler([key, opts].concat(rest));
- Read upRead up
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 hasLoadedNamespace
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
hasLoadedNamespace(ns, options = {}) {
if (!this.isInitialized) {
this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
return false;
}
- Read upRead up
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 use
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
use(module) {
if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()')
if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()')
if (module.type === 'backend') {
- Read upRead up
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];
- Read upRead up
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 = [
- Read upRead up
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
if (!this.services.backendConnector.backend || (this.options.resources && !this.options.partialBundledLanguages)) return true;
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
if (this.hasResourceBundle(lng, ns)) return true;
Avoid too many return
statements within this function. Open
if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;