HabitRPG/habitrpg

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

Summary

Maintainability
F
6 days
Test Coverage

File GET-challenges_group_groupid.test.js has 283 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  generateUser,
  generateChallenge,
  createAndPopulateGroup,
  translate as t,

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

        it('should return group challenges for member with populated leader', async () => {
          const challenges = await user.get(`/challenges/groups/${privateGuild._id}`);
    
          const foundChallenge1 = _.find(challenges, { _id: challenge._id });
          expect(foundChallenge1).to.exist;
    test/api/v3/integration/challenges/GET-challenges_group_groupid.test.js on lines 112..145

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

    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('should return group challenges for member with populated leader', async () => {
          const challenges = await user.get(`/challenges/groups/${party._id}`);
    
          const foundChallenge1 = _.find(challenges, { _id: challenge._id });
          expect(foundChallenge1).to.exist;
    test/api/v3/integration/challenges/GET-challenges_group_groupid.test.js on lines 44..77

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

    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(foundChallenge2.leader).to.eql({
            _id: user._id,
            id: user._id,
            profile: { name: user.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 238..250
    test/api/v3/integration/challenges/GET-challenges_group_groupid.test.js on lines 253..265
    test/api/v3/integration/challenges/POST-challenges_challengeId_join.test.js on lines 78..90
    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 10 locations. Consider refactoring.
    Open

          expect(foundChallenge2.leader).to.eql({
            _id: user._id,
            id: user._id,
            profile: { name: user.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/POST-challenges_challengeId_join.test.js on lines 78..90
    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 10 locations. Consider refactoring.
    Open

          expect(foundChallenge1.leader).to.eql({
            _id: user._id,
            id: user._id,
            profile: { name: user.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 253..265
    test/api/v3/integration/challenges/POST-challenges_challengeId_join.test.js on lines 78..90
    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 10 locations. Consider refactoring.
    Open

          expect(foundChallenge1.leader).to.eql({
            _id: user._id,
            id: user._id,
            profile: { name: user.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 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/POST-challenges_challengeId_join.test.js on lines 78..90
    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 2 locations. Consider refactoring.
    Open

          it('should return official challenges first', async () => {
            const challenges = await user.get('/challenges/groups/habitrpg');
    
            const foundChallengeIndex = _.findIndex(challenges, { _id: officialChallenge._id });
            expect(foundChallengeIndex).to.eql(0);
    test/api/v3/integration/challenges/GET-challenges_user.test.js on lines 259..264

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

    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

          const { group, groupLeader } = await createAndPopulateGroup({
            groupDetails: {
              name: 'TestPrivateGuild',
              type: 'guild',
              privacy: 'private',
    test/api/v3/integration/groups/PUT-groups.test.js on lines 136..143
    test/api/v3/integration/groups/PUT-groups.test.js on lines 165..172
    test/api/v3/integration/user/POST-user_purchase.test.js on lines 48..55

    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