HabitRPG/habitrpg

View on GitHub
test/helpers/api-integration/v4/object-generators.js

Summary

Maintainability
F
5 days
Test Coverage

Function createAndPopulateGroup has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function createAndPopulateGroup (settings = {}) {
  const numberOfMembers = settings.members || 0;
  const numberOfInvites = settings.invites || 0;
  const upgradeToGroupPlan = settings.upgradeToGroupPlan || false;
  const { groupDetails } = settings;
Severity: Minor
Found in test/helpers/api-integration/v4/object-generators.js - About 1 hr to fix

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

    export async function createAndPopulateGroup (settings = {}) {
      const numberOfMembers = settings.members || 0;
      const numberOfInvites = settings.invites || 0;
      const upgradeToGroupPlan = settings.upgradeToGroupPlan || false;
      const { groupDetails } = settings;
    Severity: Major
    Found in test/helpers/api-integration/v4/object-generators.js and 1 other location - About 2 days to fix
    test/helpers/api-integration/v3/object-generators.js on lines 124..170

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

    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

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

    export async function generateChallenge (challengeCreator, group, details = {}, update = {}) {
      details.group = group._id;
      details.name = details.name || 'a challenge';
      details.shortName = details.shortName || 'aChallenge';
      details.prize = details.prize || 0;
    Severity: Major
    Found in test/helpers/api-integration/v4/object-generators.js and 1 other location - About 6 hrs to fix
    test/helpers/api-integration/v3/object-generators.js on lines 177..190

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

    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

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

    export async function generateGroup (leader, details = {}, update = {}) {
      details.type = details.type || 'party';
      details.privacy = details.privacy || 'private';
      details.name = details.name || 'test group';
    
    
    Severity: Major
    Found in test/helpers/api-integration/v4/object-generators.js and 1 other location - About 4 hrs to fix
    test/helpers/api-integration/v3/object-generators.js on lines 75..86

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

    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

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

    async function _upgradeToGroupPlan (groupLeader, group) {
      const groupLeaderModel = await User.findById(groupLeader._id).exec();
    
      // Create subscription
      const paymentData = {
    Severity: Major
    Found in test/helpers/api-integration/v4/object-generators.js and 1 other location - About 3 hrs to fix
    test/helpers/api-integration/v3/object-generators.js on lines 88..106

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

    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

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

    export async function generateTodo (update = {}) {
      const type = 'todo';
      const task = new Tasks[type](update);
      await task.save({ validateBeforeSave: false });
      return task;
    Severity: Major
    Found in test/helpers/api-integration/v4/object-generators.js and 1 other location - About 1 hr to fix
    test/helpers/api-integration/v3/object-generators.js on lines 64..69

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

    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

    export async function generateDaily (update = {}) {
      const type = 'daily';
      const task = new Tasks[type](update);
      await task.save({ validateBeforeSave: false });
      return task;
    Severity: Major
    Found in test/helpers/api-integration/v4/object-generators.js and 5 other locations - About 1 hr to fix
    test/helpers/api-integration/v3/object-generators.js on lines 43..48
    test/helpers/api-integration/v3/object-generators.js on lines 50..55
    test/helpers/api-integration/v3/object-generators.js on lines 57..62
    test/helpers/api-integration/v4/object-generators.js on lines 37..42
    test/helpers/api-integration/v4/object-generators.js on lines 51..56

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

    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

    export async function generateReward (update = {}) {
      const type = 'reward';
      const task = new Tasks[type](update);
      await task.save({ validateBeforeSave: false });
      return task;
    Severity: Major
    Found in test/helpers/api-integration/v4/object-generators.js and 5 other locations - About 1 hr to fix
    test/helpers/api-integration/v3/object-generators.js on lines 43..48
    test/helpers/api-integration/v3/object-generators.js on lines 50..55
    test/helpers/api-integration/v3/object-generators.js on lines 57..62
    test/helpers/api-integration/v4/object-generators.js on lines 37..42
    test/helpers/api-integration/v4/object-generators.js on lines 44..49

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

    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

    export async function generateHabit (update = {}) {
      const type = 'habit';
      const task = new Tasks[type](update);
      await task.save({ validateBeforeSave: false });
      return task;
    Severity: Major
    Found in test/helpers/api-integration/v4/object-generators.js and 5 other locations - About 1 hr to fix
    test/helpers/api-integration/v3/object-generators.js on lines 43..48
    test/helpers/api-integration/v3/object-generators.js on lines 50..55
    test/helpers/api-integration/v3/object-generators.js on lines 57..62
    test/helpers/api-integration/v4/object-generators.js on lines 44..49
    test/helpers/api-integration/v4/object-generators.js on lines 51..56

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

    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