HabitRPG/habitrpg

View on GitHub
test/api/v3/integration/challenges/POST-challenges_challengeId_join.test.js

Summary

Maintainability
C
1 day
Test Coverage

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

    it('returns error when user has already joined the challenge', async () => {
      await authorizedUser.post(`/challenges/${challenge._id}/join`);

      await expect(authorizedUser.post(`/challenges/${challenge._id}/join`)).to.eventually.be.rejected.and.eql({
        code: 401,
test/api/v3/integration/challenges/POST-challenge_flag.test.js on lines 54..63
test/api/v3/integration/tasks/DELETE-tasks_id.test.js on lines 29..36
test/api/v3/integration/tasks/DELETE-tasks_id.test.js on lines 38..46
test/api/v3/integration/tasks/POST-tasks_id_score_direction.test.js on lines 186..194
test/api/v3/integration/tasks/POST-tasks_id_score_direction.test.js on lines 290..297
test/api/v3/integration/tasks/challenges/DELETE-tasks_id_challenge_challengeId.test.js on lines 48..56
test/api/v3/integration/tasks/groups/DELETE-group_tasks_id.test.js on lines 36..45

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

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

      expect(res.leader).to.eql({
        _id: groupLeader._id,
        id: groupLeader._id,
        profile: { name: groupLeader.profile.name },
        auth: {
test/api/v3/integration/challenges/GET-challenges_challengeId.test.js on lines 59..71
test/api/v3/integration/challenges/GET-challenges_challengeId.test.js on lines 93..105
test/api/v3/integration/challenges/GET-challenges_challengeId.test.js on lines 149..161
test/api/v3/integration/challenges/GET-challenges_challengeId.test.js on lines 183..195
test/api/v3/integration/challenges/GET-challenges_group_groupid.test.js on lines 203..215
test/api/v3/integration/challenges/GET-challenges_group_groupid.test.js on lines 218..230
test/api/v3/integration/challenges/GET-challenges_group_groupid.test.js on lines 238..250
test/api/v3/integration/challenges/GET-challenges_group_groupid.test.js on lines 253..265
test/api/v3/integration/challenges/PUT-challenges_challengeId.test.js on lines 80..92

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.group).to.eql({
        _id: group._id,
        privacy: group.privacy,
        name: group.name,
        type: group.type,
test/api/v3/integration/challenges/POST-challenges.test.js on lines 276..281
test/api/v3/integration/challenges/POST-challenges_challengeId_winner_winnerId.test.js on lines 109..114
test/api/v3/integration/challenges/PUT-challenges_challengeId.test.js on lines 70..75

Duplicated Code

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

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

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

Tuning

This issue has a mass of 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

There are no issues that match your filters.

Category
Status