HabitRPG/habitrpg

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

Summary

Maintainability
D
2 days
Test Coverage

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

    it('doesn\'t highlight user in link with url-escapable characters', async () => {
      const text = '[test](https://habitica.fandom.com/ru/@wiki/Снаряжение)';
      const result = await highlightMentions(text);
      expect(result[0]).to.equal(text);
    });
Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 1 other location - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 106..110

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

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('doesn\'t highlight user in a link without url', async () => {
      const text = '[@user2]()';
      const result = await highlightMentions(text);
      expect(result[0]).to.equal(text);
    });
Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 1 other location - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 113..117

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

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

  it('doesn\'t highlight more than 5 users', async () => {
    const text = '@user @user2 @user3 @user4 @user5 @user6';
    const result = await highlightMentions(text);
    expect(result[0]).to.equal(text);
  });
Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 13 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 32..36
test/api/unit/libs/highlightMentions.test.js on lines 69..73
test/api/unit/libs/highlightMentions.test.js on lines 75..79
test/api/unit/libs/highlightMentions.test.js on lines 81..85
test/api/unit/libs/highlightMentions.test.js on lines 87..91
test/api/unit/libs/highlightMentions.test.js on lines 93..97
test/api/unit/libs/highlightMentions.test.js on lines 130..136
test/api/unit/libs/highlightMentions.test.js on lines 138..144
test/api/unit/libs/highlightMentions.test.js on lines 146..152
test/api/unit/libs/highlightMentions.test.js on lines 172..178
test/api/unit/libs/highlightMentions.test.js on lines 180..186
test/api/unit/libs/highlightMentions.test.js on lines 188..194
test/api/unit/libs/highlightMentions.test.js on lines 196..202

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

    it('doesn\'t highlight users in link with newlines and markup', async () => {
      const text = '[Check `awesome` \nblog **written** by @user](http://www.medium.com/@user/blog)';
      const result = await highlightMentions(text);
      expect(result[0]).to.equal(text);
    });
Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 13 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 32..36
test/api/unit/libs/highlightMentions.test.js on lines 62..66
test/api/unit/libs/highlightMentions.test.js on lines 69..73
test/api/unit/libs/highlightMentions.test.js on lines 75..79
test/api/unit/libs/highlightMentions.test.js on lines 81..85
test/api/unit/libs/highlightMentions.test.js on lines 87..91
test/api/unit/libs/highlightMentions.test.js on lines 130..136
test/api/unit/libs/highlightMentions.test.js on lines 138..144
test/api/unit/libs/highlightMentions.test.js on lines 146..152
test/api/unit/libs/highlightMentions.test.js on lines 172..178
test/api/unit/libs/highlightMentions.test.js on lines 180..186
test/api/unit/libs/highlightMentions.test.js on lines 188..194
test/api/unit/libs/highlightMentions.test.js on lines 196..202

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

    it('doesn\'t highlight users in link', async () => {
      const text = 'http://www.medium.com/@user/blog';
      const result = await highlightMentions(text);
      expect(result[0]).to.equal(text);
    });
Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 13 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 32..36
test/api/unit/libs/highlightMentions.test.js on lines 62..66
test/api/unit/libs/highlightMentions.test.js on lines 75..79
test/api/unit/libs/highlightMentions.test.js on lines 81..85
test/api/unit/libs/highlightMentions.test.js on lines 87..91
test/api/unit/libs/highlightMentions.test.js on lines 93..97
test/api/unit/libs/highlightMentions.test.js on lines 130..136
test/api/unit/libs/highlightMentions.test.js on lines 138..144
test/api/unit/libs/highlightMentions.test.js on lines 146..152
test/api/unit/libs/highlightMentions.test.js on lines 172..178
test/api/unit/libs/highlightMentions.test.js on lines 180..186
test/api/unit/libs/highlightMentions.test.js on lines 188..194
test/api/unit/libs/highlightMentions.test.js on lines 196..202

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

    it('doesn\'t highlight users in link text', async () => {
      const text = '[Check awesome blog written by @user](http://www.medium.com/@user/blog)';
      const result = await highlightMentions(text);
      expect(result[0]).to.equal(text);
    });
Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 13 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 32..36
test/api/unit/libs/highlightMentions.test.js on lines 62..66
test/api/unit/libs/highlightMentions.test.js on lines 69..73
test/api/unit/libs/highlightMentions.test.js on lines 75..79
test/api/unit/libs/highlightMentions.test.js on lines 81..85
test/api/unit/libs/highlightMentions.test.js on lines 93..97
test/api/unit/libs/highlightMentions.test.js on lines 130..136
test/api/unit/libs/highlightMentions.test.js on lines 138..144
test/api/unit/libs/highlightMentions.test.js on lines 146..152
test/api/unit/libs/highlightMentions.test.js on lines 172..178
test/api/unit/libs/highlightMentions.test.js on lines 180..186
test/api/unit/libs/highlightMentions.test.js on lines 188..194
test/api/unit/libs/highlightMentions.test.js on lines 196..202

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

    it('doesn\'t highlight user in inline code block', async () => {
      const text = '`@user`';

      const result = await highlightMentions(text);

Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 13 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 32..36
test/api/unit/libs/highlightMentions.test.js on lines 62..66
test/api/unit/libs/highlightMentions.test.js on lines 69..73
test/api/unit/libs/highlightMentions.test.js on lines 75..79
test/api/unit/libs/highlightMentions.test.js on lines 81..85
test/api/unit/libs/highlightMentions.test.js on lines 87..91
test/api/unit/libs/highlightMentions.test.js on lines 93..97
test/api/unit/libs/highlightMentions.test.js on lines 138..144
test/api/unit/libs/highlightMentions.test.js on lines 146..152
test/api/unit/libs/highlightMentions.test.js on lines 172..178
test/api/unit/libs/highlightMentions.test.js on lines 180..186
test/api/unit/libs/highlightMentions.test.js on lines 188..194
test/api/unit/libs/highlightMentions.test.js on lines 196..202

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

    it('doesn\'t highlight user in indented code block', async () => {
      const text = '      @user';

      const result = await highlightMentions(text);

Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 13 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 32..36
test/api/unit/libs/highlightMentions.test.js on lines 62..66
test/api/unit/libs/highlightMentions.test.js on lines 69..73
test/api/unit/libs/highlightMentions.test.js on lines 75..79
test/api/unit/libs/highlightMentions.test.js on lines 81..85
test/api/unit/libs/highlightMentions.test.js on lines 87..91
test/api/unit/libs/highlightMentions.test.js on lines 93..97
test/api/unit/libs/highlightMentions.test.js on lines 130..136
test/api/unit/libs/highlightMentions.test.js on lines 138..144
test/api/unit/libs/highlightMentions.test.js on lines 172..178
test/api/unit/libs/highlightMentions.test.js on lines 180..186
test/api/unit/libs/highlightMentions.test.js on lines 188..194
test/api/unit/libs/highlightMentions.test.js on lines 196..202

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

    it('github issue 12118, method crashes when square brackets are used', async () => {
      const text = '[test]';

      const result = await highlightMentions(text);

Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 13 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 32..36
test/api/unit/libs/highlightMentions.test.js on lines 62..66
test/api/unit/libs/highlightMentions.test.js on lines 69..73
test/api/unit/libs/highlightMentions.test.js on lines 75..79
test/api/unit/libs/highlightMentions.test.js on lines 81..85
test/api/unit/libs/highlightMentions.test.js on lines 87..91
test/api/unit/libs/highlightMentions.test.js on lines 93..97
test/api/unit/libs/highlightMentions.test.js on lines 130..136
test/api/unit/libs/highlightMentions.test.js on lines 138..144
test/api/unit/libs/highlightMentions.test.js on lines 146..152
test/api/unit/libs/highlightMentions.test.js on lines 180..186
test/api/unit/libs/highlightMentions.test.js on lines 188..194
test/api/unit/libs/highlightMentions.test.js on lines 196..202

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

    it('github issue 12586, method crashes when empty link is used', async () => {
      const text = '[]()';

      const result = await highlightMentions(text);

Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 13 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 32..36
test/api/unit/libs/highlightMentions.test.js on lines 62..66
test/api/unit/libs/highlightMentions.test.js on lines 69..73
test/api/unit/libs/highlightMentions.test.js on lines 75..79
test/api/unit/libs/highlightMentions.test.js on lines 81..85
test/api/unit/libs/highlightMentions.test.js on lines 87..91
test/api/unit/libs/highlightMentions.test.js on lines 93..97
test/api/unit/libs/highlightMentions.test.js on lines 130..136
test/api/unit/libs/highlightMentions.test.js on lines 138..144
test/api/unit/libs/highlightMentions.test.js on lines 146..152
test/api/unit/libs/highlightMentions.test.js on lines 172..178
test/api/unit/libs/highlightMentions.test.js on lines 180..186
test/api/unit/libs/highlightMentions.test.js on lines 196..202

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

    it('doesn\'t highlight user in fenced code block', async () => {
      const text = 'Text\n\n```\n// code referencing @user\n```\n\nText';

      const result = await highlightMentions(text);

Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 13 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 32..36
test/api/unit/libs/highlightMentions.test.js on lines 62..66
test/api/unit/libs/highlightMentions.test.js on lines 69..73
test/api/unit/libs/highlightMentions.test.js on lines 75..79
test/api/unit/libs/highlightMentions.test.js on lines 81..85
test/api/unit/libs/highlightMentions.test.js on lines 87..91
test/api/unit/libs/highlightMentions.test.js on lines 93..97
test/api/unit/libs/highlightMentions.test.js on lines 130..136
test/api/unit/libs/highlightMentions.test.js on lines 146..152
test/api/unit/libs/highlightMentions.test.js on lines 172..178
test/api/unit/libs/highlightMentions.test.js on lines 180..186
test/api/unit/libs/highlightMentions.test.js on lines 188..194
test/api/unit/libs/highlightMentions.test.js on lines 196..202

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

    it('github issue 12586, method crashes when link without title is used', async () => {
      const text = '[](www.google.com)';

      const result = await highlightMentions(text);

Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 13 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 32..36
test/api/unit/libs/highlightMentions.test.js on lines 62..66
test/api/unit/libs/highlightMentions.test.js on lines 69..73
test/api/unit/libs/highlightMentions.test.js on lines 75..79
test/api/unit/libs/highlightMentions.test.js on lines 81..85
test/api/unit/libs/highlightMentions.test.js on lines 87..91
test/api/unit/libs/highlightMentions.test.js on lines 93..97
test/api/unit/libs/highlightMentions.test.js on lines 130..136
test/api/unit/libs/highlightMentions.test.js on lines 138..144
test/api/unit/libs/highlightMentions.test.js on lines 146..152
test/api/unit/libs/highlightMentions.test.js on lines 172..178
test/api/unit/libs/highlightMentions.test.js on lines 180..186
test/api/unit/libs/highlightMentions.test.js on lines 188..194

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

    it('doesn\'t highlight user in link between brackets', async () => {
      const text = '(http://www.medium.com/@user/blog)';
      const result = await highlightMentions(text);
      expect(result[0]).to.equal(text);
    });
Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 13 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 32..36
test/api/unit/libs/highlightMentions.test.js on lines 62..66
test/api/unit/libs/highlightMentions.test.js on lines 69..73
test/api/unit/libs/highlightMentions.test.js on lines 81..85
test/api/unit/libs/highlightMentions.test.js on lines 87..91
test/api/unit/libs/highlightMentions.test.js on lines 93..97
test/api/unit/libs/highlightMentions.test.js on lines 130..136
test/api/unit/libs/highlightMentions.test.js on lines 138..144
test/api/unit/libs/highlightMentions.test.js on lines 146..152
test/api/unit/libs/highlightMentions.test.js on lines 172..178
test/api/unit/libs/highlightMentions.test.js on lines 180..186
test/api/unit/libs/highlightMentions.test.js on lines 188..194
test/api/unit/libs/highlightMentions.test.js on lines 196..202

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

    it('doesn\'t highlight user in an autolink', async () => {
      const text = '<http://www.medium.com/@user/blog>';
      const result = await highlightMentions(text);
      expect(result[0]).to.equal(text);
    });
Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 13 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 32..36
test/api/unit/libs/highlightMentions.test.js on lines 62..66
test/api/unit/libs/highlightMentions.test.js on lines 69..73
test/api/unit/libs/highlightMentions.test.js on lines 75..79
test/api/unit/libs/highlightMentions.test.js on lines 87..91
test/api/unit/libs/highlightMentions.test.js on lines 93..97
test/api/unit/libs/highlightMentions.test.js on lines 130..136
test/api/unit/libs/highlightMentions.test.js on lines 138..144
test/api/unit/libs/highlightMentions.test.js on lines 146..152
test/api/unit/libs/highlightMentions.test.js on lines 172..178
test/api/unit/libs/highlightMentions.test.js on lines 180..186
test/api/unit/libs/highlightMentions.test.js on lines 188..194
test/api/unit/libs/highlightMentions.test.js on lines 196..202

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

  it('doesn\'t change text without mentions', async () => {
    const text = 'some chat text';
    const result = await highlightMentions(text);
    expect(result[0]).to.equal(text);
  });
Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 13 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 62..66
test/api/unit/libs/highlightMentions.test.js on lines 69..73
test/api/unit/libs/highlightMentions.test.js on lines 75..79
test/api/unit/libs/highlightMentions.test.js on lines 81..85
test/api/unit/libs/highlightMentions.test.js on lines 87..91
test/api/unit/libs/highlightMentions.test.js on lines 93..97
test/api/unit/libs/highlightMentions.test.js on lines 130..136
test/api/unit/libs/highlightMentions.test.js on lines 138..144
test/api/unit/libs/highlightMentions.test.js on lines 146..152
test/api/unit/libs/highlightMentions.test.js on lines 172..178
test/api/unit/libs/highlightMentions.test.js on lines 180..186
test/api/unit/libs/highlightMentions.test.js on lines 188..194
test/api/unit/libs/highlightMentions.test.js on lines 196..202

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

    it('does highlight same content properly', async () => {
      const text = '@user `@user`';

      const result = await highlightMentions(text);

Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 5 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 38..42
test/api/unit/libs/highlightMentions.test.js on lines 44..48
test/api/unit/libs/highlightMentions.test.js on lines 50..54
test/api/unit/libs/highlightMentions.test.js on lines 56..60
test/api/unit/libs/highlightMentions.test.js on lines 154..160

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

    it('does highlight user that\'s after in-line code block', async () => {
      const text = '`<code />` for @user';

      const result = await highlightMentions(text);

Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 5 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 38..42
test/api/unit/libs/highlightMentions.test.js on lines 44..48
test/api/unit/libs/highlightMentions.test.js on lines 50..54
test/api/unit/libs/highlightMentions.test.js on lines 56..60
test/api/unit/libs/highlightMentions.test.js on lines 162..168

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

  it('highlights existing users', async () => {
    const text = '@user: message';
    const result = await highlightMentions(text);
    expect(result[0]).to.equal('[@user](/profile/111): message');
  });
Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 5 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 44..48
test/api/unit/libs/highlightMentions.test.js on lines 50..54
test/api/unit/libs/highlightMentions.test.js on lines 56..60
test/api/unit/libs/highlightMentions.test.js on lines 154..160
test/api/unit/libs/highlightMentions.test.js on lines 162..168

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

  it('highlights special characters', async () => {
    const text = '@user-dash: message @user_underscore';
    const result = await highlightMentions(text);
    expect(result[0]).to.equal('[@user-dash](/profile/444): message [@user_underscore](/profile/555)');
  });
Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 5 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 38..42
test/api/unit/libs/highlightMentions.test.js on lines 50..54
test/api/unit/libs/highlightMentions.test.js on lines 56..60
test/api/unit/libs/highlightMentions.test.js on lines 154..160
test/api/unit/libs/highlightMentions.test.js on lines 162..168

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

    it('github issue 12138, method crashes when regex chars are used in code block', async () => {
      const text = '`[test]`';

      const result = await highlightMentions(text);

Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 13 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 32..36
test/api/unit/libs/highlightMentions.test.js on lines 62..66
test/api/unit/libs/highlightMentions.test.js on lines 69..73
test/api/unit/libs/highlightMentions.test.js on lines 75..79
test/api/unit/libs/highlightMentions.test.js on lines 81..85
test/api/unit/libs/highlightMentions.test.js on lines 87..91
test/api/unit/libs/highlightMentions.test.js on lines 93..97
test/api/unit/libs/highlightMentions.test.js on lines 130..136
test/api/unit/libs/highlightMentions.test.js on lines 138..144
test/api/unit/libs/highlightMentions.test.js on lines 146..152
test/api/unit/libs/highlightMentions.test.js on lines 172..178
test/api/unit/libs/highlightMentions.test.js on lines 188..194
test/api/unit/libs/highlightMentions.test.js on lines 196..202

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

  it('doesn\'t highlight nonexisting users', async () => {
    const text = '@nouser message';
    const result = await highlightMentions(text);
    expect(result[0]).to.equal('@nouser message');
  });
Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 5 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 38..42
test/api/unit/libs/highlightMentions.test.js on lines 44..48
test/api/unit/libs/highlightMentions.test.js on lines 56..60
test/api/unit/libs/highlightMentions.test.js on lines 154..160
test/api/unit/libs/highlightMentions.test.js on lines 162..168

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

  it('highlights multiple existing users', async () => {
    const text = '@user message (@user2) @user3 @user';
    const result = await highlightMentions(text);
    expect(result[0]).to.equal('[@user](/profile/111) message ([@user2](/profile/222)) [@user3](/profile/333) [@user](/profile/111)');
  });
Severity: Major
Found in test/api/unit/libs/highlightMentions.test.js and 5 other locations - About 1 hr to fix
test/api/unit/libs/highlightMentions.test.js on lines 38..42
test/api/unit/libs/highlightMentions.test.js on lines 44..48
test/api/unit/libs/highlightMentions.test.js on lines 50..54
test/api/unit/libs/highlightMentions.test.js on lines 154..160
test/api/unit/libs/highlightMentions.test.js on lines 162..168

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

There are no issues that match your filters.

Category
Status