Lambda-School-Labs/Labs26-StorySquad-BE-TeamB

View on GitHub

Showing 61 of 124 total issues

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

const children2 = [...new Array(8)].map((i, idx) => ({
  Name: `${faker.name.firstName()} (Cohort2)`,
  PIN: `${bc.hashSync(`0000`, process.env.BCRYPT_ROUNDS || 6)}`,
  // ParentID: `${Math.floor((idx + 4) / 4)}`,
  ParentID: `${(idx % 4) + 1}`,
Severity: Major
Found in data/seeds/006_Children.js and 1 other location - About 1 day to fix
data/seeds/006_Children.js on lines 41..57

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

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

const children3 = [...new Array(8)].map((i, idx) => ({
  Name: `${faker.name.firstName()} (Cohort3)`,
  PIN: `${bc.hashSync(`0000`, process.env.BCRYPT_ROUNDS || 6)}`,
  // ParentID: `${Math.floor((idx + 4) / 4)}`,
  ParentID: `${(idx % 4) + 1}`,
Severity: Major
Found in data/seeds/006_Children.js and 1 other location - About 1 day to fix
data/seeds/006_Children.js on lines 23..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 316.

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

const updateWinsForChildren = async () => {
    const winningTeam = await getWinningTeam()
    const children = await getChildrenWithTeam()
    const winningChildren = children.filter(child => child.TeamID === winningTeam[0].ID)
    for (const winningChild of winningChildren) {
Severity: Major
Found in api/cronTasks/cronTasks.js and 1 other location - About 4 hrs to fix
api/cronTasks/cronTasks.js on lines 41..48

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

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

const updateLosesForChildren = async () => {
    const winningTeam = await getWinningTeam()
    const children = await getChildrenWithTeam()
    const losingChildren = children.filter(child => child.TeamID !== winningTeam[0].ID)
    for (const losingChild of losingChildren) {
Severity: Major
Found in api/cronTasks/cronTasks.js and 1 other location - About 4 hrs to fix
api/cronTasks/cronTasks.js on lines 32..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 119.

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

const submissions2 = [...new Array(16)].map((i, idx) => ({
  ChildID: `${idx + 1}`,
  StoryID: 2,
  CohortID: `${cohortIDer(idx)}`,
  HasRead: true,
Severity: Major
Found in data/seeds/007_Submissions.js and 1 other location - About 3 hrs to fix
data/seeds/007_Submissions.js on lines 42..52

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

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

const submissions3 = [...new Array(16)].map((i, idx) => ({
  ChildID: `${idx + 1}`,
  StoryID: 3,
  CohortID: `${cohortIDer(idx)}`,
  HasRead: true,
Severity: Major
Found in data/seeds/007_Submissions.js and 1 other location - About 3 hrs to fix
data/seeds/007_Submissions.js on lines 29..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 104.

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

const pointsShareDateValidation = (request, response, next) => {
    if (currentDayOfTheWeek === 3) {
        console.log('It is Wednesday');
        const payload = {message: 'It is Wednesday', day: currentDayOfTheWeek};
        response.payload = payload;
Severity: Major
Found in api/middleware/dateValidation.js and 1 other location - About 2 hrs to fix
api/middleware/dateValidation.js on lines 15..22

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

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

const moderationDateValidation = (request, response, next) => {
    if (currentDayOfTheWeek === 2) {
        console.log('It is Tuesday');
        const payload = {message: 'It is Tuesday', day: currentDayOfTheWeek};
        response.payload = payload;
Severity: Major
Found in api/middleware/dateValidation.js and 1 other location - About 2 hrs to fix
api/middleware/dateValidation.js on lines 24..31

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

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

exports.down = function (knex) {
  return knex.schema
    .table('Squads', (t) => {
      t.dropColumn('Winner');
    })
Severity: Major
Found in data/migrations/20201016163412_gamification-4.js and 1 other location - About 2 hrs to fix
data/migrations/20201203165213_add-emojis-columns.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 76.

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

exports.down = function(knex) {
    return knex.schema
    .table('Writing', (t) => {
        t.dropColumn('Emoji');
    })
Severity: Major
Found in data/migrations/20201203165213_add-emojis-columns.js and 1 other location - About 2 hrs to fix
data/migrations/20201016163412_gamification-4.js on lines 15..23

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

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

Function up has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.up = function (knex) {
  return knex.schema
    .createTable('Faceoffs', (t) => {
      t.increments('ID');
      t.integer('Points').notNullable();
Severity: Major
Found in data/migrations/20201012104127_gamification-3.js - About 2 hrs to fix

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

          faceoff.Emojis1 = await conn(`${faceoffType} AS T`)
            .join("Submissions AS S", "S.ID", "T.SubmissionID")
            .where("S.ID", faceoff.SubmissionID1)
            .where("S.ChildID", ChildID)
            .select("T.Emoji").first();
    Severity: Major
    Found in api/game/gameHelpers/faceoffRetrieval.js and 1 other location - About 1 hr to fix
    api/game/gameHelpers/faceoffRetrieval.js on lines 34..38

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

    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

          faceoff.Emojis2 = await conn(`${faceoffType} AS T`)
            .join("Submissions AS S", "S.ID", "T.SubmissionID")
            .where("S.ID", faceoff.SubmissionID2)
            .where("S.ChildID", ChildID)
            .select("T.Emoji").first();
    Severity: Major
    Found in api/game/gameHelpers/faceoffRetrieval.js and 1 other location - About 1 hr to fix
    api/game/gameHelpers/faceoffRetrieval.js on lines 29..33

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

    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

    const writings1 = [...new Array(64)].map((i, idx) => ({
      URL: `https://picsum.photos/id/${idx + 1}/400`,
      // URL: `https://source.unsplash.com/featured/?{writing}`,
      PageNum: 1,
      SubmissionID: `${idx + 1}`,
    Severity: Major
    Found in data/seeds/008_Writings_Drawings.js and 1 other location - About 1 hr to fix
    data/seeds/008_Writings_Drawings.js on lines 7..12

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

    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

    const writings2 = [...new Array(64)].map((i, idx) => ({
      URL: `https://picsum.photos/id/${idx + 101}/400`,
      // URL: `https://source.unsplash.com/featured/?{writing}`,
      PageNum: 2,
      SubmissionID: `${idx + 1}`,
    Severity: Major
    Found in data/seeds/008_Writings_Drawings.js and 1 other location - About 1 hr to fix
    data/seeds/008_Writings_Drawings.js on lines 1..6

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

    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

    Function fileUploadHandler has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const fileUploadHandler = async (req, res, next) => {
      // Create a new instance of a multiparty form object
      const form = new multiparty.Form();
      // Parse the form data from the request body into multiparty
      form.parse(req, async (error, fields, files) => {
    Severity: Minor
    Found in api/middleware/fileUpload.js - About 1 hr to fix

      Function up has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.up = function (knex) {
        return knex.schema
          .createTable('Submissions', (t) => {
            t.increments('ID');
            t.integer('ChildID')
      Severity: Minor
      Found in data/migrations/20200928102812_child_submissions.js - About 1 hr to fix

        Function up has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        exports.up = function (knex) {
          return knex.schema
            .createTable('Squads', (t) => {
              // Squads table just creates a point of reference to connect teams
              t.increments('ID');
        Severity: Minor
        Found in data/migrations/20201012093856_gamification-1.js - About 1 hr to fix

          Function getFaceoffsForSquad has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          const getFaceoffsForSquad = (SquadID, ChildID = null) => {
            // return db.transaction(async (trx) => {
            //   try {
            //     // Get the faceoffs from the Faceoffs table in the db
            //     const faceoffs = await faceoff.getSubIdsForFaceoffs(trx, SquadID);
          Severity: Minor
          Found in api/game/gameModel.js - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

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

          exports.up = function (knex) {
            return knex.schema
              .createTable('Parents', (t) => {
                t.increments('ID');
                t.string('Name').notNullable();
          Severity: Minor
          Found in data/migrations/20200902161643_new_schema.js - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language