itsmingjie/infinity

View on GitHub

Showing 18 of 47 total issues

File db.js has 540 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * This is the primary service that drives the
 * connection between the verification server
 * and the database.
 */
Severity: Major
Found in services/db.js - About 1 day to fix

    Function solve has 104 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const solve = (e) => {
      e.preventDefault()
      const csrfToken = document.getElementById('csrfToken').value
      const solution = solutionBox.value
    
    
    Severity: Major
    Found in static/assets/scripts/solve.js - About 4 hrs to fix

      File game.js has 291 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /**
       * Handles all puzzle-related services
       * including listing/submission etc.
       */
      
      
      Severity: Minor
      Found in routes/game.js - About 3 hrs to fix

        Function validateUser has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        const validateUser = (name, password) => {
          return new Promise((resolve, reject) => {
            pool
              .connect()
              .then((client) => {
        Severity: Minor
        Found in services/db.js - About 2 hrs 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 importTeams has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const importTeams = (file) => {
          return new Promise((resolve, reject) => {
            const fileRows = []
        
            csv
        Severity: Minor
        Found in lib/csv.js - About 2 hrs to fix

          Function createUser has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const createUser = (
            name,
            password,
            division,
            affiliation,
          Severity: Minor
          Found in services/db.js - About 1 hr to fix

            Function getUser has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const getUser = (id) => {
              return new Promise((resolve, reject) => {
                pool
                  .connect()
                  .then((client) => {
            Severity: Minor
            Found in services/db.js - About 1 hr to fix

              Function fireConfetti has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const fireConfetti = () => {
                var count = 200
                var defaults = {
                  origin: { y: 0.7 }
                }
              Severity: Minor
              Found in static/assets/scripts/solve.js - About 1 hr to fix

                Function authCheck has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                const authCheck = (admin) => async (req, res, next) => {
                  if (!req.user) {
                    return res.redirect(`/account/login?requested=true&path=${req.originalUrl}`)
                  } else {
                    const user = await db.getUser(req.user.id)
                Severity: Minor
                Found in lib/utils.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 restock has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const restock = async () => {
                  const puzzles = await airtable.getUnlockedPuzzles(true)
                  const levels = await airtable.getLevels()
                  const hints = await airtable.getHints()
                
                
                Severity: Minor
                Found in routes/game.js - About 1 hr to fix

                  Function userFinish has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const userFinish = (uid, finished, finalized) => {
                    return new Promise((resolve, reject) => {
                      pool
                        .connect()
                        .then((client) => {
                  Severity: Minor
                  Found in services/db.js - About 1 hr to fix

                    Function validateUser has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const validateUser = (name, password) => {
                      return new Promise((resolve, reject) => {
                        pool
                          .connect()
                          .then((client) => {
                    Severity: Minor
                    Found in services/db.js - About 1 hr to fix

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

                      const giveHintCredit = (staffId, uid, amount) => {
                        amount = amount || 1
                      
                        pool.connect().then((client) => {
                          client.query('BEGIN') // protection against data racing
                      Severity: Minor
                      Found in services/db.js - About 1 hr to fix

                        Function getUser has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                        const getUser = (id) => {
                          return new Promise((resolve, reject) => {
                            pool
                              .connect()
                              .then((client) => {
                        Severity: Minor
                        Found in services/db.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 createAttempt has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const createAttempt = (uid, puzzle, attempt, value, success) => {
                          return new Promise((resolve, reject) => {
                            pool
                              .connect()
                              .then((client) => {
                        Severity: Minor
                        Found in services/db.js - About 1 hr to fix

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

                          const lockdownCheck = (flag, adminBypass) => async (req, res, next) => {
                            if (res.locals.global[flag]) {
                              if (adminBypass && res.locals.team && res.locals.team.isAdmin) {
                                // bypassed admin
                                res.locals.bypassed = flag
                          Severity: Minor
                          Found in lib/utils.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

                          Function userFinish has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const userFinish = (uid, finished, finalized) => {
                            return new Promise((resolve, reject) => {
                              pool
                                .connect()
                                .then((client) => {
                          Severity: Minor
                          Found in services/db.js - About 35 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 createUser has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const createUser = (
                            name,
                            password,
                            division,
                            affiliation,
                          Severity: Minor
                          Found in services/db.js - About 25 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