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

View on GitHub

Showing 61 of 124 total issues

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

const send = (res, error, name = '') => {
  console.log({ error: error.message });
  let status, message;
  if (error.message.includes('NotFound')) {
    status = 404;
Severity: Minor
Found in lib/errorHandler.js - About 1 hr to fix

    Function getLeaderBoardData has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const getLeaderBoardData = async () =>{
    
        const output = []
    
        const derivedTable = await db('Children AS C')
    Severity: Minor
    Found in api/leaderboard/leadBoardModel.js - About 1 hr to fix

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

        return conn('Submissions AS S')
          .join('Writing AS W', 'S.ID', 'W.SubmissionID')
          .join('Drawing AS D', 'S.ID', 'D.SubmissionID')
          .join('Children AS C', 'S.ChildID', 'C.ID')
          .join('Avatars AS A', 'C.AvatarID', 'A.ID')
      Severity: Major
      Found in lib/dbOps.js and 1 other location - About 1 hr to fix
      api/game/gameModel.js on lines 11..17

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

        return db('Squads AS S')
          .join('Teams AS T', 'S.ID', 'T.SquadID')
          .join('Members AS M', 'T.ID', 'M.TeamID')
          .join('Submissions AS Sub', 'Sub.ID', 'M.SubmissionID')
          .join('Children AS C', 'C.ID', 'Sub.ChildID')
      Severity: Major
      Found in api/game/gameModel.js and 1 other location - About 1 hr to fix
      lib/dbOps.js on lines 22..35

      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

      router.get('/', authRequired, async (req, res) => {
        const cohortId = req.query.cohortId;
      
        crudOperationsManager.getById(res, Stories.getByCohortId, 'Story', cohortId);
      });
      Severity: Major
      Found in api/stories/storyRouter.js and 2 other locations - About 1 hr to fix
      api/game/gameRouter.js on lines 260..264
      api/parent/parentRouter.js on lines 106..110

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

      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

      router.get('/squad', authRequired, (req, res) => {
        const childId = req.query.childId;
      
        crudOperationsManager.getById(res, Game.getSquadIDFromChildID, 'Child', childId);
      });
      Severity: Major
      Found in api/game/gameRouter.js and 2 other locations - About 1 hr to fix
      api/parent/parentRouter.js on lines 106..110
      api/stories/storyRouter.js on lines 102..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 58.

      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

      router.get('/viz', authRequired, (req, res) => {
        const childId = req.query.childId;
      
        crudOperationsManager.getAll(res, Parents.getVisualizations, 'Child', childId);
      });
      Severity: Major
      Found in api/parent/parentRouter.js and 2 other locations - About 1 hr to fix
      api/game/gameRouter.js on lines 260..264
      api/stories/storyRouter.js on lines 102..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 58.

      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 VSequence has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const VSequence = (squads, data) =>{
          //pull squad keys that which are equivilent to squad numbers
          let allSquadNums = Object.keys(squads)
          //converts all indecies into integers
          let formatedSquadNum = []
      Severity: Minor
      Found in api/mod/BallotGeneration.js - About 1 hr to fix

        Function formatTeam has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const formatTeam = (submissions) => {
          // Initialize response object
          const team = {};
          // Iterate over submission pages
          submissions.forEach(
        Severity: Minor
        Found in lib/formatHelpers.js - About 1 hr to fix

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

          const add = (parent) => {
            return db('Parents')
              .insert({ ...parent, PIN: hashPin(parent.PIN) })
              .returning('ID');
          };
          Severity: Major
          Found in api/parent/parentModel.js and 1 other location - About 1 hr to fix
          api/child/childModel.js on lines 69..76

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

          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

          module.exports = {
            getFormattedTeam,
            assignPoints,
            getFaceoffsForSquad,
            getSquadIDFromChildID,
          Severity: Major
          Found in api/game/gameModel.js and 1 other location - About 1 hr to fix
          api/parent/parentModel.js on lines 150..160

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

          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

            router.delete('/:id', authRequired, (req, res) => {
              // Pull achievement ID out of the URL params
              const { id } = req.params;
            
              crudOperationsManager.update(res, achievements.remove, 'Achievements', id);
          Severity: Major
          Found in api/Achievements/achieveRouter.js and 1 other location - About 1 hr to fix
          api/Achievements/achieveRouter.js on lines 17..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 57.

          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 add = (child) => {
            return db('Children')
              .insert({
                ...child,
                PIN: hashPin(child.PIN),
          Severity: Major
          Found in api/child/childModel.js and 1 other location - About 1 hr to fix
          api/parent/parentModel.js on lines 43..47

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

          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

          module.exports = {
            getAll,
            getById,
            getByEmail,
            add,
          Severity: Major
          Found in api/parent/parentModel.js and 1 other location - About 1 hr to fix
          api/game/gameModel.js on lines 251..261

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

          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

          router.get('/:id', authRequired, (req, res) => {
              // Pull achievement ID out of the URL params
              const { id } = req.params;
            
              crudOperationsManager.getById(res, achievements.getById, 'Achievements', id);
          Severity: Major
          Found in api/Achievements/achieveRouter.js and 1 other location - About 1 hr to fix
          api/Achievements/achieveRouter.js on lines 40..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 57.

          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 incrementVotesCasted has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const incrementVotesCasted =(squads, ID, FO) =>{
              let iSquads = squads[`${ID}`]
              let newArr = []
              let returnObject = {}
              iSquads.forEach(s =>{
          Severity: Minor
          Found in api/mod/BallotGeneration.js - About 1 hr to fix

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

            exports.down = function (knex) {
              return knex.schema
                .dropTableIfExists('Members')
                .dropTableIfExists('Teams')
                .dropTableIfExists('Squads')
            Severity: Major
            Found in data/migrations/20201012093856_gamification-1.js and 2 other locations - About 1 hr to fix
            data/migrations/20200902161643_new_schema.js on lines 39..45
            data/migrations/20201012104127_gamification-3.js on lines 55..61

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

            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

            router.get('/', authRequired, async (req, res) => {
              const { Email } = req.profile;
            
              crudOperationsManager.getAll(res, Parents.getProfilesByEmail, 'Profile', Email);
            });
            Severity: Minor
            Found in api/profile/profileRouter.js and 1 other location - About 55 mins to fix
            api/game/gameRouter.js on lines 376..380

            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

            router.get('/faceoffs/:id', authRequired, (req, res) =>{
              const { id } = req.params;
            
              crudOperationsManager.getById(res, Game.getFaceOffByID, 'Faceoffs', id);
            })
            Severity: Minor
            Found in api/game/gameRouter.js and 1 other location - About 55 mins to fix
            api/profile/profileRouter.js on lines 98..102

            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

            Function clusterGeneration has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            const clusterGeneration = () => {
              return db.transaction(async (trx) => {
                try {
                  const dsReq = {};
                  // Pull a list of all cohorts
            Severity: Minor
            Found in api/mod/modHelpers/clusterGeneration.js - About 55 mins 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

            Severity
            Category
            Status
            Source
            Language