HabitRPG/habitrpg

View on GitHub
test/api/unit/libs/language.test.js

Summary

Maintainability
C
1 day
Test Coverage

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

    it('uses the user preferred language if avalaible', () => {
      const user = {
        preferences: {
          language: 'it',
        },
Severity: Major
Found in test/api/unit/libs/language.test.js and 1 other location - About 1 hr to fix
test/api/unit/libs/language.test.js on lines 27..35

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 56.

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

    it('falls back to english if the user preferred language is not avalaible', () => {
      const user = {
        preferences: {
          language: 'bla',
        },
Severity: Major
Found in test/api/unit/libs/language.test.js and 1 other location - About 1 hr to fix
test/api/unit/libs/language.test.js on lines 17..25

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 56.

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 11 locations. Consider refactoring.
Open

    it('uses browser specificed language', () => {
      req.headers['accept-language'] = 'pt';

      expect(getLanguageFromBrowser(req)).to.equal('pt');
    });
Severity: Major
Found in test/api/unit/libs/language.test.js and 10 other locations - About 50 mins to fix
test/api/unit/libs/language.test.js on lines 45..49
test/api/unit/libs/language.test.js on lines 51..55
test/api/unit/libs/language.test.js on lines 57..61
test/api/unit/libs/language.test.js on lines 63..67
test/api/unit/libs/language.test.js on lines 69..73
test/api/unit/libs/language.test.js on lines 75..79
test/api/unit/libs/language.test.js on lines 81..85
test/api/unit/libs/language.test.js on lines 87..91
test/api/unit/libs/language.test.js on lines 93..97
test/api/unit/libs/language.test.js on lines 99..103

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 51.

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 11 locations. Consider refactoring.
Open

    it('uses first language in series if browser specifies multiple', () => {
      req.headers['accept-language'] = 'he, pt, it';

      expect(getLanguageFromBrowser(req)).to.equal('he');
    });
Severity: Major
Found in test/api/unit/libs/language.test.js and 10 other locations - About 50 mins to fix
test/api/unit/libs/language.test.js on lines 39..43
test/api/unit/libs/language.test.js on lines 51..55
test/api/unit/libs/language.test.js on lines 57..61
test/api/unit/libs/language.test.js on lines 63..67
test/api/unit/libs/language.test.js on lines 69..73
test/api/unit/libs/language.test.js on lines 75..79
test/api/unit/libs/language.test.js on lines 81..85
test/api/unit/libs/language.test.js on lines 87..91
test/api/unit/libs/language.test.js on lines 93..97
test/api/unit/libs/language.test.js on lines 99..103

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 51.

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 11 locations. Consider refactoring.
Open

    it('skips invalid lanaguages and uses first language in series if browser specifies multiple', () => {
      req.headers['accept-language'] = 'blah, he, pt, it';

      expect(getLanguageFromBrowser(req)).to.equal('he');
    });
Severity: Major
Found in test/api/unit/libs/language.test.js and 10 other locations - About 50 mins to fix
test/api/unit/libs/language.test.js on lines 39..43
test/api/unit/libs/language.test.js on lines 45..49
test/api/unit/libs/language.test.js on lines 57..61
test/api/unit/libs/language.test.js on lines 63..67
test/api/unit/libs/language.test.js on lines 69..73
test/api/unit/libs/language.test.js on lines 75..79
test/api/unit/libs/language.test.js on lines 81..85
test/api/unit/libs/language.test.js on lines 87..91
test/api/unit/libs/language.test.js on lines 93..97
test/api/unit/libs/language.test.js on lines 99..103

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 51.

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 11 locations. Consider refactoring.
Open

    it('uses es_419 if applicable es-languages are passed in', () => {
      req.headers['accept-language'] = 'es-mx';

      expect(getLanguageFromBrowser(req)).to.equal('es_419');
    });
Severity: Major
Found in test/api/unit/libs/language.test.js and 10 other locations - About 50 mins to fix
test/api/unit/libs/language.test.js on lines 39..43
test/api/unit/libs/language.test.js on lines 45..49
test/api/unit/libs/language.test.js on lines 51..55
test/api/unit/libs/language.test.js on lines 57..61
test/api/unit/libs/language.test.js on lines 63..67
test/api/unit/libs/language.test.js on lines 69..73
test/api/unit/libs/language.test.js on lines 81..85
test/api/unit/libs/language.test.js on lines 87..91
test/api/unit/libs/language.test.js on lines 93..97
test/api/unit/libs/language.test.js on lines 99..103

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 51.

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 11 locations. Consider refactoring.
Open

    it('uses normal version of language if specialized locale is passed in', () => {
      req.headers['accept-language'] = 'fr-CA';

      expect(getLanguageFromBrowser(req)).to.equal('fr');
    });
Severity: Major
Found in test/api/unit/libs/language.test.js and 10 other locations - About 50 mins to fix
test/api/unit/libs/language.test.js on lines 39..43
test/api/unit/libs/language.test.js on lines 45..49
test/api/unit/libs/language.test.js on lines 51..55
test/api/unit/libs/language.test.js on lines 57..61
test/api/unit/libs/language.test.js on lines 69..73
test/api/unit/libs/language.test.js on lines 75..79
test/api/unit/libs/language.test.js on lines 81..85
test/api/unit/libs/language.test.js on lines 87..91
test/api/unit/libs/language.test.js on lines 93..97
test/api/unit/libs/language.test.js on lines 99..103

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 51.

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 11 locations. Consider refactoring.
Open

    it('uses es_419 if multiple es languages are passed in', () => {
      req.headers['accept-language'] = 'es-GT, es-MX, es-CR';

      expect(getLanguageFromBrowser(req)).to.equal('es_419');
    });
Severity: Major
Found in test/api/unit/libs/language.test.js and 10 other locations - About 50 mins to fix
test/api/unit/libs/language.test.js on lines 39..43
test/api/unit/libs/language.test.js on lines 45..49
test/api/unit/libs/language.test.js on lines 51..55
test/api/unit/libs/language.test.js on lines 57..61
test/api/unit/libs/language.test.js on lines 63..67
test/api/unit/libs/language.test.js on lines 69..73
test/api/unit/libs/language.test.js on lines 75..79
test/api/unit/libs/language.test.js on lines 87..91
test/api/unit/libs/language.test.js on lines 93..97
test/api/unit/libs/language.test.js on lines 99..103

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 51.

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 11 locations. Consider refactoring.
Open

    it('uses normal version of language if specialized locale is passed in', () => {
      req.headers['accept-language'] = 'fr-CA';

      expect(getLanguageFromBrowser(req)).to.equal('fr');
    });
Severity: Major
Found in test/api/unit/libs/language.test.js and 10 other locations - About 50 mins to fix
test/api/unit/libs/language.test.js on lines 39..43
test/api/unit/libs/language.test.js on lines 45..49
test/api/unit/libs/language.test.js on lines 51..55
test/api/unit/libs/language.test.js on lines 63..67
test/api/unit/libs/language.test.js on lines 69..73
test/api/unit/libs/language.test.js on lines 75..79
test/api/unit/libs/language.test.js on lines 81..85
test/api/unit/libs/language.test.js on lines 87..91
test/api/unit/libs/language.test.js on lines 93..97
test/api/unit/libs/language.test.js on lines 99..103

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 51.

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 11 locations. Consider refactoring.
Open

    it('uses english if browser specified language is not compatible', () => {
      req.headers['accept-language'] = 'blah';

      expect(getLanguageFromBrowser(req)).to.equal('en');
    });
Severity: Major
Found in test/api/unit/libs/language.test.js and 10 other locations - About 50 mins to fix
test/api/unit/libs/language.test.js on lines 39..43
test/api/unit/libs/language.test.js on lines 45..49
test/api/unit/libs/language.test.js on lines 51..55
test/api/unit/libs/language.test.js on lines 57..61
test/api/unit/libs/language.test.js on lines 63..67
test/api/unit/libs/language.test.js on lines 69..73
test/api/unit/libs/language.test.js on lines 75..79
test/api/unit/libs/language.test.js on lines 81..85
test/api/unit/libs/language.test.js on lines 87..91
test/api/unit/libs/language.test.js on lines 99..103

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 51.

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 11 locations. Consider refactoring.
Open

    it('uses english if browser does not specify', () => {
      req.headers['accept-language'] = '';

      expect(getLanguageFromBrowser(req)).to.equal('en');
    });
Severity: Major
Found in test/api/unit/libs/language.test.js and 10 other locations - About 50 mins to fix
test/api/unit/libs/language.test.js on lines 39..43
test/api/unit/libs/language.test.js on lines 45..49
test/api/unit/libs/language.test.js on lines 51..55
test/api/unit/libs/language.test.js on lines 57..61
test/api/unit/libs/language.test.js on lines 63..67
test/api/unit/libs/language.test.js on lines 69..73
test/api/unit/libs/language.test.js on lines 75..79
test/api/unit/libs/language.test.js on lines 81..85
test/api/unit/libs/language.test.js on lines 87..91
test/api/unit/libs/language.test.js on lines 93..97

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 51.

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 11 locations. Consider refactoring.
Open

    it('zh', () => {
      req.headers['accept-language'] = 'zh-TW';

      expect(getLanguageFromBrowser(req)).to.equal('zh_TW');
    });
Severity: Major
Found in test/api/unit/libs/language.test.js and 10 other locations - About 50 mins to fix
test/api/unit/libs/language.test.js on lines 39..43
test/api/unit/libs/language.test.js on lines 45..49
test/api/unit/libs/language.test.js on lines 51..55
test/api/unit/libs/language.test.js on lines 57..61
test/api/unit/libs/language.test.js on lines 63..67
test/api/unit/libs/language.test.js on lines 69..73
test/api/unit/libs/language.test.js on lines 75..79
test/api/unit/libs/language.test.js on lines 81..85
test/api/unit/libs/language.test.js on lines 93..97
test/api/unit/libs/language.test.js on lines 99..103

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 51.

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 11 locations. Consider refactoring.
Open

    it('uses es if es is passed in', () => {
      req.headers['accept-language'] = 'es';

      expect(getLanguageFromBrowser(req)).to.equal('es');
    });
Severity: Major
Found in test/api/unit/libs/language.test.js and 10 other locations - About 50 mins to fix
test/api/unit/libs/language.test.js on lines 39..43
test/api/unit/libs/language.test.js on lines 45..49
test/api/unit/libs/language.test.js on lines 51..55
test/api/unit/libs/language.test.js on lines 57..61
test/api/unit/libs/language.test.js on lines 63..67
test/api/unit/libs/language.test.js on lines 75..79
test/api/unit/libs/language.test.js on lines 81..85
test/api/unit/libs/language.test.js on lines 87..91
test/api/unit/libs/language.test.js on lines 93..97
test/api/unit/libs/language.test.js on lines 99..103

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 51.

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