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

View on GitHub

Showing 13 of 124 total issues

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

    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

            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

                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

                    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

                      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

                      Function submitVote has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const submitVote = (vote) => {
                        // return db('Votes').insert(vote).returning('ID');
                        return db.transaction(async (trx) => {
                          try {
                            const { Vote, MemberID, FaceoffID, subEmojis1, subEmojis2 } = vote;
                      Severity: Minor
                      Found in api/game/gameModel.js - About 45 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