Function chooseLocale
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function chooseLocale(names: string[]): Locale {
let next;
let locale;
let i = 0;
- 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 mergeConfigs
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export function mergeConfigs(parentConfig: LocaleData,
childConfig: LocaleData) {
const res: LocaleData = Object.assign({}, parentConfig);
for (const childProp in childConfig) {
- 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 defineLocale
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function defineLocale(name: string, config?: LocaleData): Locale {
if (config === null) {
// useful for testing
delete locales[name];
globalLocale = getLocale('en');
Function ordinal
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
ordinal(num: number): string {
const b = num % 10;
const output =
toInt((num % 100) / 10) === 1
? 'th'
- 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 updateLocale
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function updateLocale(name: string, config?: LocaleData): Locale {
let _config = config;
if (_config != null) {
let parentConfig = baseConfig;
- 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 defineLocale
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function defineLocale(name: string, config?: LocaleData): Locale {
if (config === null) {
// useful for testing
delete locales[name];
globalLocale = getLocale('en');
- 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 mergeConfigs
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function mergeConfigs(parentConfig: LocaleData,
childConfig: LocaleData) {
const res: LocaleData = Object.assign({}, parentConfig);
for (const childProp in childConfig) {
Function getSetGlobalLocale
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export function getSetGlobalLocale(key?: string | string[], values?: LocaleData): string {
let data: Locale;
if (key) {
if (isUndefined(values)) {
- 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"