valor-software/angular2-bootstrap

View on GitHub
src/chronos/i18n/cs.ts

Summary

Maintainability
D
3 days
Test Coverage

Function translate has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
Open

function translate(num: number, withoutSuffix: boolean, key: string, isFuture: boolean): string {
  const result = num + ' ';

  switch (key) {
    case 's':  // a few seconds / in a few seconds / a few seconds ago
Severity: Minor
Found in src/chronos/i18n/cs.ts - About 1 day 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 translate has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function translate(num: number, withoutSuffix: boolean, key: string, isFuture: boolean): string {
  const result = num + ' ';

  switch (key) {
    case 's':  // a few seconds / in a few seconds / a few seconds ago
Severity: Major
Found in src/chronos/i18n/cs.ts - About 2 hrs to fix

    Avoid too many return statements within this function.
    Open

            return result + 'hodinami';
    Severity: Major
    Found in src/chronos/i18n/cs.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return result + (plural(num) ? 'hodiny' : 'hodin');
      Severity: Major
      Found in src/chronos/i18n/cs.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return result + 'dny';
        Severity: Major
        Found in src/chronos/i18n/cs.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return result + (plural(num) ? 'roky' : 'let');
          Severity: Major
          Found in src/chronos/i18n/cs.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return result + 'měsíci';
            Severity: Major
            Found in src/chronos/i18n/cs.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return result + (plural(num) ? 'měsíce' : 'měsíců');
              Severity: Major
              Found in src/chronos/i18n/cs.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return result + (plural(num) ? 'dny' : 'dní');
                Severity: Major
                Found in src/chronos/i18n/cs.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return result + 'lety';
                  Severity: Major
                  Found in src/chronos/i18n/cs.ts - About 30 mins to fix

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                      shortMonthsParse: (function (monthsShort) {
                        let i, _shortMonthsParse = [];
                        for (i = 0; i < 12; i++) {
                          _shortMonthsParse[i] = new RegExp('^' + monthsShort[i] + '$', 'i');
                        }
                    Severity: Major
                    Found in src/chronos/i18n/cs.ts and 1 other location - About 2 hrs to fix
                    src/chronos/i18n/cs.ts on lines 99..105

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 78.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                      longMonthsParse: (function (months) {
                        let i, _longMonthsParse = [];
                        for (i = 0; i < 12; i++) {
                          _longMonthsParse[i] = new RegExp('^' + months[i] + '$', 'i');
                        }
                    Severity: Major
                    Found in src/chronos/i18n/cs.ts and 1 other location - About 2 hrs to fix
                    src/chronos/i18n/cs.ts on lines 92..98

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 78.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 5 locations. Consider refactoring.
                    Open

                      relativeTime: {
                        future: 'za %s',
                        past: 'před %s',
                        s: translate,
                        ss: translate,
                    Severity: Major
                    Found in src/chronos/i18n/cs.ts and 4 other locations - About 2 hrs to fix
                    src/chronos/i18n/fi.ts on lines 85..100
                    src/chronos/i18n/hu.ts on lines 85..100
                    src/chronos/i18n/mn.ts on lines 75..90
                    src/chronos/i18n/sl.ts on lines 150..165

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 76.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 6 locations. Consider refactoring.
                    Open

                        case 'MM': // 9 months / in 9 months / 9 months ago
                          if (withoutSuffix || isFuture) {
                            return result + (plural(num) ? 'měsíce' : 'měsíců');
                          } else {
                            return result + 'měsíci';
                    Severity: Major
                    Found in src/chronos/i18n/cs.ts and 5 other locations - About 35 mins to fix
                    src/chronos/i18n/cs.ts on lines 25..30
                    src/chronos/i18n/cs.ts on lines 34..39
                    src/chronos/i18n/cs.ts on lines 43..48
                    src/chronos/i18n/cs.ts on lines 52..57
                    src/chronos/i18n/cs.ts on lines 70..75

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 47.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 6 locations. Consider refactoring.
                    Open

                        case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago
                          if (withoutSuffix || isFuture) {
                            return result + (plural(num) ? 'minuty' : 'minut');
                          } else {
                            return result + 'minutami';
                    Severity: Major
                    Found in src/chronos/i18n/cs.ts and 5 other locations - About 35 mins to fix
                    src/chronos/i18n/cs.ts on lines 25..30
                    src/chronos/i18n/cs.ts on lines 43..48
                    src/chronos/i18n/cs.ts on lines 52..57
                    src/chronos/i18n/cs.ts on lines 61..66
                    src/chronos/i18n/cs.ts on lines 70..75

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 47.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 6 locations. Consider refactoring.
                    Open

                        case 'hh': // 9 hours / in 9 hours / 9 hours ago
                          if (withoutSuffix || isFuture) {
                            return result + (plural(num) ? 'hodiny' : 'hodin');
                          } else {
                            return result + 'hodinami';
                    Severity: Major
                    Found in src/chronos/i18n/cs.ts and 5 other locations - About 35 mins to fix
                    src/chronos/i18n/cs.ts on lines 25..30
                    src/chronos/i18n/cs.ts on lines 34..39
                    src/chronos/i18n/cs.ts on lines 52..57
                    src/chronos/i18n/cs.ts on lines 61..66
                    src/chronos/i18n/cs.ts on lines 70..75

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 47.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 6 locations. Consider refactoring.
                    Open

                        case 'dd': // 9 days / in 9 days / 9 days ago
                          if (withoutSuffix || isFuture) {
                            return result + (plural(num) ? 'dny' : 'dní');
                          } else {
                            return result + 'dny';
                    Severity: Major
                    Found in src/chronos/i18n/cs.ts and 5 other locations - About 35 mins to fix
                    src/chronos/i18n/cs.ts on lines 25..30
                    src/chronos/i18n/cs.ts on lines 34..39
                    src/chronos/i18n/cs.ts on lines 43..48
                    src/chronos/i18n/cs.ts on lines 61..66
                    src/chronos/i18n/cs.ts on lines 70..75

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 47.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 6 locations. Consider refactoring.
                    Open

                        case 'yy': // 9 years / in 9 years / 9 years ago
                          if (withoutSuffix || isFuture) {
                            return result + (plural(num) ? 'roky' : 'let');
                          } else {
                            return result + 'lety';
                    Severity: Major
                    Found in src/chronos/i18n/cs.ts and 5 other locations - About 35 mins to fix
                    src/chronos/i18n/cs.ts on lines 25..30
                    src/chronos/i18n/cs.ts on lines 34..39
                    src/chronos/i18n/cs.ts on lines 43..48
                    src/chronos/i18n/cs.ts on lines 52..57
                    src/chronos/i18n/cs.ts on lines 61..66

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 47.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 6 locations. Consider refactoring.
                    Open

                        case 'ss': // 9 seconds / in 9 seconds / 9 seconds ago
                          if (withoutSuffix || isFuture) {
                            return result + (plural(num) ? 'sekundy' : 'sekund');
                          } else {
                            return result + 'sekundami';
                    Severity: Major
                    Found in src/chronos/i18n/cs.ts and 5 other locations - About 35 mins to fix
                    src/chronos/i18n/cs.ts on lines 34..39
                    src/chronos/i18n/cs.ts on lines 43..48
                    src/chronos/i18n/cs.ts on lines 52..57
                    src/chronos/i18n/cs.ts on lines 61..66
                    src/chronos/i18n/cs.ts on lines 70..75

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 47.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    There are no issues that match your filters.

                    Category
                    Status