HabitRPG/habitrpg

View on GitHub
website/client/src/store/actions/tasks.js

Summary

Maintainability
D
2 days
Test Coverage

Function create has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function create (store, createdTask) {
  // Treat all create actions as if we are adding multiple tasks
  const payload = Array.isArray(createdTask) ? createdTask : [createdTask];

  payload.forEach(t => {
Severity: Minor
Found in website/client/src/store/actions/tasks.js - About 1 hr to fix

    Function order has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function order (store, [rawTasks, tasksOrder]) {
      const tasks = {
        habits: [],
        dailys: [],
        todos: [],
    Severity: Minor
    Found in website/client/src/store/actions/tasks.js - About 1 hr to fix

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

          tasksOfType.forEach((task, index) => {
            const taskId = task._id;
            const i = orderOfType[index] === taskId ? index : orderOfType.indexOf(taskId);
            if (i === -1) {
              unorderedTasks.push(task);
      Severity: Major
      Found in website/client/src/store/actions/tasks.js and 1 other location - About 3 hrs to fix
      website/client/src/libs/store/helpers/orderTasks.js on lines 11..19

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

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

      export async function move (store, payload) {
        const response = await axios.post(`/api/v4/tasks/${payload.taskId}/move/to/${payload.position}`);
        return response.data.data;
      }
      Severity: Major
      Found in website/client/src/store/actions/tasks.js and 6 other locations - About 1 hr to fix
      website/client/src/store/actions/challenges.js on lines 95..99
      website/client/src/store/actions/tasks.js on lines 211..214
      website/client/src/store/actions/tasks.js on lines 216..219
      website/client/src/store/actions/tasks.js on lines 226..229
      website/client/src/store/actions/tasks.js on lines 257..260
      website/client/src/store/actions/user.js on lines 114..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 62.

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

      export async function moveGroupTask (store, payload) {
        const response = await axios.post(`/api/v4/group-tasks/${payload.taskId}/move/to/${payload.position}`);
        return response.data.data;
      }
      Severity: Major
      Found in website/client/src/store/actions/tasks.js and 6 other locations - About 1 hr to fix
      website/client/src/store/actions/challenges.js on lines 95..99
      website/client/src/store/actions/tasks.js on lines 211..214
      website/client/src/store/actions/tasks.js on lines 216..219
      website/client/src/store/actions/tasks.js on lines 226..229
      website/client/src/store/actions/tasks.js on lines 252..255
      website/client/src/store/actions/user.js on lines 114..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 62.

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

      export async function unassignTask (store, payload) {
        const response = await axios.post(`/api/v4/tasks/${payload.taskId}/unassign/${payload.userId}`);
        return response.data.data;
      }
      Severity: Major
      Found in website/client/src/store/actions/tasks.js and 6 other locations - About 1 hr to fix
      website/client/src/store/actions/challenges.js on lines 95..99
      website/client/src/store/actions/tasks.js on lines 216..219
      website/client/src/store/actions/tasks.js on lines 226..229
      website/client/src/store/actions/tasks.js on lines 252..255
      website/client/src/store/actions/tasks.js on lines 257..260
      website/client/src/store/actions/user.js on lines 114..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 62.

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

      export async function approve (store, payload) {
        const response = await axios.post(`/api/v4/tasks/${payload.taskId}/approve/${payload.userId}`);
        return response.data.data;
      }
      Severity: Major
      Found in website/client/src/store/actions/tasks.js and 6 other locations - About 1 hr to fix
      website/client/src/store/actions/challenges.js on lines 95..99
      website/client/src/store/actions/tasks.js on lines 211..214
      website/client/src/store/actions/tasks.js on lines 216..219
      website/client/src/store/actions/tasks.js on lines 252..255
      website/client/src/store/actions/tasks.js on lines 257..260
      website/client/src/store/actions/user.js on lines 114..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 62.

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

      export async function needsWork (store, payload) {
        const response = await axios.post(`/api/v4/tasks/${payload.taskId}/needs-work/${payload.userId}`);
        return response.data.data;
      }
      Severity: Major
      Found in website/client/src/store/actions/tasks.js and 6 other locations - About 1 hr to fix
      website/client/src/store/actions/challenges.js on lines 95..99
      website/client/src/store/actions/tasks.js on lines 211..214
      website/client/src/store/actions/tasks.js on lines 226..229
      website/client/src/store/actions/tasks.js on lines 252..255
      website/client/src/store/actions/tasks.js on lines 257..260
      website/client/src/store/actions/user.js on lines 114..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 62.

      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

      export async function createChallengeTasks (store, payload) {
        const response = await axios.post(`/api/v4/tasks/challenge/${payload.challengeId}`, payload.tasks);
        return response.data.data;
      }
      Severity: Major
      Found in website/client/src/store/actions/tasks.js and 2 other locations - About 1 hr to fix
      website/client/src/store/actions/tasks.js on lines 201..204
      website/client/src/store/actions/tasks.js on lines 206..209

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

      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

      export async function assignTask (store, payload) {
        const response = await axios.post(`/api/v4/tasks/${payload.taskId}/assign`, payload.assignedUserIds);
        return response.data.data;
      }
      Severity: Major
      Found in website/client/src/store/actions/tasks.js and 2 other locations - About 1 hr to fix
      website/client/src/store/actions/tasks.js on lines 186..189
      website/client/src/store/actions/tasks.js on lines 201..204

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

      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

      export async function createGroupTasks (store, payload) {
        const response = await axios.post(`/api/v4/tasks/group/${payload.groupId}`, payload.tasks);
        return response.data.data;
      }
      Severity: Major
      Found in website/client/src/store/actions/tasks.js and 2 other locations - About 1 hr to fix
      website/client/src/store/actions/tasks.js on lines 186..189
      website/client/src/store/actions/tasks.js on lines 206..209

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

      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

      export async function getCompletedGroupTasks (store, payload) {
        const response = await axios.get(`/api/v4/tasks/group/${payload.groupId}?type=completedTodos`);
        return response.data.data;
      }
      Severity: Major
      Found in website/client/src/store/actions/tasks.js and 9 other locations - About 55 mins to fix
      website/client/src/store/actions/challenges.js on lines 19..23
      website/client/src/store/actions/challenges.js on lines 57..61
      website/client/src/store/actions/challenges.js on lines 63..67
      website/client/src/store/actions/challenges.js on lines 69..73
      website/client/src/store/actions/challenges.js on lines 108..111
      website/client/src/store/actions/chat.js on lines 5..9
      website/client/src/store/actions/tasks.js on lines 181..184
      website/client/src/store/actions/tasks.js on lines 191..194
      website/client/src/store/actions/tasks.js on lines 221..224

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

      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

      export async function getGroupTasks (store, payload) {
        const response = await axios.get(`/api/v4/tasks/group/${payload.groupId}`);
        return response.data.data;
      }
      Severity: Major
      Found in website/client/src/store/actions/tasks.js and 9 other locations - About 55 mins to fix
      website/client/src/store/actions/challenges.js on lines 19..23
      website/client/src/store/actions/challenges.js on lines 57..61
      website/client/src/store/actions/challenges.js on lines 63..67
      website/client/src/store/actions/challenges.js on lines 69..73
      website/client/src/store/actions/challenges.js on lines 108..111
      website/client/src/store/actions/chat.js on lines 5..9
      website/client/src/store/actions/tasks.js on lines 181..184
      website/client/src/store/actions/tasks.js on lines 196..199
      website/client/src/store/actions/tasks.js on lines 221..224

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

      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

      export async function getChallengeTasks (store, payload) {
        const response = await axios.get(`/api/v4/tasks/challenge/${payload.challengeId}`);
        return response.data.data;
      }
      Severity: Major
      Found in website/client/src/store/actions/tasks.js and 9 other locations - About 55 mins to fix
      website/client/src/store/actions/challenges.js on lines 19..23
      website/client/src/store/actions/challenges.js on lines 57..61
      website/client/src/store/actions/challenges.js on lines 63..67
      website/client/src/store/actions/challenges.js on lines 69..73
      website/client/src/store/actions/challenges.js on lines 108..111
      website/client/src/store/actions/chat.js on lines 5..9
      website/client/src/store/actions/tasks.js on lines 191..194
      website/client/src/store/actions/tasks.js on lines 196..199
      website/client/src/store/actions/tasks.js on lines 221..224

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

      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

      export async function getGroupApprovals (store, payload) {
        const response = await axios.get(`/api/v4/approvals/group/${payload.groupId}`);
        return response.data.data;
      }
      Severity: Major
      Found in website/client/src/store/actions/tasks.js and 9 other locations - About 55 mins to fix
      website/client/src/store/actions/challenges.js on lines 19..23
      website/client/src/store/actions/challenges.js on lines 57..61
      website/client/src/store/actions/challenges.js on lines 63..67
      website/client/src/store/actions/challenges.js on lines 69..73
      website/client/src/store/actions/challenges.js on lines 108..111
      website/client/src/store/actions/chat.js on lines 5..9
      website/client/src/store/actions/tasks.js on lines 181..184
      website/client/src/store/actions/tasks.js on lines 191..194
      website/client/src/store/actions/tasks.js on lines 196..199

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

      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

            if (!tasksCreatedCount) {
              setLocalSetting(CONSTANTS.keyConstants.TASKS_CREATED_COUNT, 1);
            } else {
              setLocalSetting(CONSTANTS.keyConstants.TASKS_CREATED_COUNT, Number(tasksCreatedCount) + 1);
            }
      Severity: Minor
      Found in website/client/src/store/actions/tasks.js and 1 other location - About 55 mins to fix
      website/client/src/mixins/scoreTask.js on lines 70..74

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

      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