HabitRPG/habitrpg

View on GitHub
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js

Summary

Maintainability
F
4 days
Test Coverage

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

  it('returns an error if req.query.limit is not an integer', async () => {
    const group = await generateGroup(user, { type: 'party', privacy: 'private' });
    const challenge = await generateChallenge(user, group);
    const anotherUser = await generateUser();

test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 33..43
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 115..125
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 127..137

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

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

  it('returns an error if req.query.limit is under 1', async () => {
    const group = await generateGroup(user, { type: 'party', privacy: 'private' });
    const challenge = await generateChallenge(user, group);
    const anotherUser = await generateUser();

test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 33..43
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 115..125
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 139..149

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

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

  it('fails if user isn\'t in the private group and isn\'t challenge leader', async () => {
    const group = await generateGroup(user, { type: 'party', privacy: 'private' });
    const challenge = await generateChallenge(user, group);
    const anotherUser = await generateUser();

test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 115..125
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 127..137
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 139..149

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

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

  it('returns an error if req.query.limit is over 60', async () => {
    const group = await generateGroup(user, { type: 'party', privacy: 'private' });
    const challenge = await generateChallenge(user, group);
    const anotherUser = await generateUser();

test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 33..43
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 127..137
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 139..149

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

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

    expect(res[0]).to.eql({
      _id: groupLeader._id,
      id: groupLeader._id,
      profile: { name: groupLeader.profile.name },
      auth: {
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 79..91
test/api/v3/integration/groups/GET-groups_groupId_invites.test.js on lines 50..62
test/api/v3/integration/groups/GET-groups_groupId_members.test.js on lines 56..68

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

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

    expect(res[0]).to.eql({
      _id: user._id,
      id: user._id,
      profile: { name: user.profile.name },
      auth: {
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 59..71
test/api/v3/integration/groups/GET-groups_groupId_invites.test.js on lines 50..62
test/api/v3/integration/groups/GET-groups_groupId_members.test.js on lines 56..68

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

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

  it('validates optional req.query.lastId to be an UUID', async () => {
    await expect(user.get(`/challenges/${generateUUID()}/members?lastId=invalidUUID`)).to.eventually.be.rejected.and.eql({
      code: 400,
      error: 'BadRequest',
      message: t('invalidReqParams'),
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 25..31
test/api/v3/integration/challenges/GET-challenges_challengeId_members_memberId.test.js on lines 16..22
test/api/v3/integration/challenges/GET-challenges_challengeId_members_memberId.test.js on lines 24..30
test/api/v3/integration/challenges/POST-challenge_flag.test.js on lines 29..36
test/api/v3/integration/challenges/POST-challenge_flag_clear.test.js on lines 32..39
test/api/v3/integration/challenges/POST-challenge_flag_clear.test.js on lines 41..48
test/api/v3/integration/groups/GET-groups_groupId_invites.test.js on lines 24..30
test/api/v3/integration/groups/GET-groups_groupId_members.test.js on lines 33..39
test/api/v3/integration/tasks/GET-tasks_challenge_challengeId.test.js on lines 46..52
test/api/v3/integration/tasks/POST-tasks_id_score_direction.test.js on lines 44..50
test/api/v3/integration/tasks/POST-tasks_move_taskId_to_position.test.js on lines 14..20
test/api/v3/integration/tasks/POST-tasks_move_taskId_to_position.test.js on lines 22..28
test/api/v3/integration/tasks/POST-tasks_unlink-one_taskId.test.js on lines 63..70
test/api/v3/integration/tasks/challenges/DELETE-tasks_id_challenge_challengeId.test.js on lines 30..36
test/api/v4/inbox/DELETE-inbox_messages_messageId.test.js on lines 37..44
test/api/v4/news/DELETE-news.test.js on lines 31..37
test/api/v4/news/GET-news_id.test.js on lines 22..28
test/api/v4/news/PUT-news_newsId.test.js on lines 33..39

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

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

  it('fails if challenge doesn\'t exist', async () => {
    await expect(user.get(`/challenges/${generateUUID()}/members`)).to.eventually.be.rejected.and.eql({
      code: 404,
      error: 'NotFound',
      message: t('challengeNotFound'),
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 17..23
test/api/v3/integration/challenges/GET-challenges_challengeId_members_memberId.test.js on lines 16..22
test/api/v3/integration/challenges/GET-challenges_challengeId_members_memberId.test.js on lines 24..30
test/api/v3/integration/challenges/POST-challenge_flag.test.js on lines 29..36
test/api/v3/integration/challenges/POST-challenge_flag_clear.test.js on lines 32..39
test/api/v3/integration/challenges/POST-challenge_flag_clear.test.js on lines 41..48
test/api/v3/integration/groups/GET-groups_groupId_invites.test.js on lines 24..30
test/api/v3/integration/groups/GET-groups_groupId_members.test.js on lines 33..39
test/api/v3/integration/tasks/GET-tasks_challenge_challengeId.test.js on lines 46..52
test/api/v3/integration/tasks/POST-tasks_id_score_direction.test.js on lines 44..50
test/api/v3/integration/tasks/POST-tasks_move_taskId_to_position.test.js on lines 14..20
test/api/v3/integration/tasks/POST-tasks_move_taskId_to_position.test.js on lines 22..28
test/api/v3/integration/tasks/POST-tasks_unlink-one_taskId.test.js on lines 63..70
test/api/v3/integration/tasks/challenges/DELETE-tasks_id_challenge_challengeId.test.js on lines 30..36
test/api/v4/inbox/DELETE-inbox_messages_messageId.test.js on lines 37..44
test/api/v4/news/DELETE-news.test.js on lines 31..37
test/api/v4/news/GET-news_id.test.js on lines 22..28
test/api/v4/news/PUT-news_newsId.test.js on lines 33..39

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

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

    for (let i = 0; i < 8; i += 1) {
      usersToGenerate.push(generateUser({ challenges: [challenge._id] }));
    }
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 102..104
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 157..159

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

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

    for (let i = 0; i < 31; i += 1) {
      usersToGenerate.push(generateUser({ challenges: [challenge._id] }));
    }
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 157..159
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 206..208

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

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

    for (let i = 0; i < 62; i += 1) {
      usersToGenerate.push(generateUser({ challenges: [challenge._id] }));
    }
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 102..104
test/api/v3/integration/challenges/GET-challenges_challengeId_members.test.js on lines 206..208

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

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

    const res2 = await user.get(`/challenges/${challenge._id}/members?lastId=${res[res.length - 1]._id}`);
test/api/v3/integration/groups/GET-groups_groupId_invites.test.js on lines 196..196
test/api/v3/integration/groups/GET-groups_groupId_members.test.js on lines 231..231

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

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