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.
*/
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
File game.js
has 291 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* Handles all puzzle-related services
* including listing/submission etc.
*/
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) => {
- Read upRead up
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
Function createUser
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
const createUser = (
name,
password,
division,
affiliation,
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) => {
Function fireConfetti
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
const fireConfetti = () => {
var count = 200
var defaults = {
origin: { y: 0.7 }
}
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)
- Read upRead up
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()
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) => {
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) => {
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
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) => {
- Read upRead up
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) => {
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
- Read upRead up
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) => {
- Read upRead up
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,
- Read upRead up
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"