valor-software/ng2-bootstrap

View on GitHub
src/chronos/locale/locales.ts

Summary

Maintainability
C
1 day
Test Coverage

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;

Severity: Minor
Found in src/chronos/locale/locales.ts - About 1 hr 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 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) {
Severity: Minor
Found in src/chronos/locale/locales.ts - About 1 hr 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 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');
Severity: Minor
Found in src/chronos/locale/locales.ts - About 1 hr to fix

    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'
    Severity: Minor
    Found in src/chronos/locale/locales.ts - About 1 hr 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 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;
    Severity: Minor
    Found in src/chronos/locale/locales.ts - About 1 hr 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 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');
    Severity: Minor
    Found in src/chronos/locale/locales.ts - About 1 hr 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 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) {
    Severity: Minor
    Found in src/chronos/locale/locales.ts - About 1 hr to fix

      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)) {
      Severity: Minor
      Found in src/chronos/locale/locales.ts - 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

      There are no issues that match your filters.

      Category
      Status