Showing 9 of 9 total issues
Function translate
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
translate(translationId, options) {
if(isEmpty(translationId)) { throw new Error('Translation id required.'); }
if((typeof translationId !== 'string' && !Array.isArray(translationId) && typeof translationId !== 'object') || translationId instanceof Date) { throw new Error('Type not supported for translation id.'); }
if(Array.isArray(translationId)) {
- 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 setLocale
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
setLocale(locale) {
if(!locale) { throw new Error('Locale required.'); }
if(typeof locale !== 'string' && !Array.isArray(locale)) { throw new Error('Type not supported for locale.'); }
var exists = (locale) => {
- 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 getTranslation
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
getTranslation(translationId, languageKey) {
var langKey = this.fallbacks[languageKey] || languageKey;
if(Array.isArray(langKey)) {
for(let key of langKey) {
let translation = this.getTranslation(translationId, key);
- 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 pluralize
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
pluralize(translatedText, options) {
if(isEmpty(translatedText)) { throw new Error('Translated text required.'); }
if(typeof translatedText !== 'object' && !this.pluralizer) { throw new Error('Type not supported for translated text when used default pluralization.'); }
if(typeof translatedText !== 'string' && this.pluralizer) { throw new Error('Type not supported for translated text when used custom pluralization.'); }
if(typeof options !== 'number' && !options) { throw new Error('Options required.'); }
- 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 translate
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
translate(translationId, options) {
if(isEmpty(translationId)) { throw new Error('Translation id required.'); }
if((typeof translationId !== 'string' && !Array.isArray(translationId) && typeof translationId !== 'object') || translationId instanceof Date) { throw new Error('Type not supported for translation id.'); }
if(Array.isArray(translationId)) {
Function setOptions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
setOptions(options) {
options = options || {};
this.urlTemplate = options.urlTemplate || 'locales/{locale}.json';
this.locales = options.locales || [];
- 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 interpolate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
interpolate(translatedText, interpolationParameters) {
if(!translatedText) { throw new Error('Translated text required.'); }
if(typeof translatedText !== 'string') { throw new Error('Type not supported for translated text.'); }
if(!interpolationParameters) { throw new Error('Interpolation parameters required.'); }
- 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 get
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
get(translationId) {
var options = {};
var interpolationParameters = [];
if(arguments && arguments.length > 1) {
- 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 isEmpty
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function isEmpty(value) {
if(!value) {
return true;
}
- 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"