Showing 10 of 36 total issues
File tasks.js
has 440 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
const passport = require('passport')
const logger = require('../logger.js')
const User = require('../models/user')
const List = require('../models/list')
const Task = require('../models/task')
Function archiveTasks
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const archiveTasks = function(tasks, userId, listId) {
return new Promise((resolve, reject) => {
let taskList = null
if ('tasks' in tasks) {
taskList = tasks.tasks.split(',')
Function connection
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const connection = function(ws, req) {
const location = url.parse(req.url, true)
// should probs not be hardcoded???
if (
(location.pathname !== '/a/ws' && location.pathname !== '/ws') ||
Function tasksDetails
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const tasksDetails = function(fullDetails = false, reqQuery, userId, listId) {
return new Promise((resolve, reject) => {
const taskModel = {
model: Task,
attributes: ['id', 'updatedAt', 'createdAt']
Function updateSingle
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const updateSingle = function(model) {
return new Promise(function(resolve, reject) {
const newData = req.body.tasks[model.id]
if (
model.updatedAt.getTime() - UPDATE_THRESHOLD <
Avoid deeply nested control flow statements. Open
Open
if (req.body.order.indexOf(key) === -1) {
shouldUpdate = false
}
Avoid deeply nested control flow statements. Open
Open
if (key === 'name') {
payload[key] = (newData[key] || '').substring(0, 255) // STRING
} else if (key === 'notes') {
payload[key] = (newData[key] || '').substring(0, 51200) // 50KB
} else if (key === 'priority') {
Avoid deeply nested control flow statements. Open
Open
if (shouldUpdate) {
payload.order = req.body.order
}
Function mapUserToGuid
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
const mapUserToGuid = async (username, createAccount = true) => {
let id = userCache.get(username)
if (id !== undefined) {
return 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 tasksDetails
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
const tasksDetails = function(fullDetails = false, reqQuery, userId, listId) {
return new Promise((resolve, reject) => {
const taskModel = {
model: Task,
attributes: ['id', 'updatedAt', 'createdAt']
- 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"