nitrotasks/nitro-server

View on GitHub

Showing 10 of 36 total issues

File tasks.js has 440 lines of code (exceeds 250 allowed). Consider refactoring.
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')
Severity: Minor
Found in lib/controllers/tasks.js - About 6 hrs to fix

    Function archiveTasks has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const archiveTasks = function(tasks, userId, listId) {
      return new Promise((resolve, reject) => {
        let taskList = null
        if ('tasks' in tasks) {
          taskList = tasks.tasks.split(',')
    Severity: Major
    Found in lib/controllers/helpers.js - About 2 hrs to fix

      Function connection has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      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') ||
      Severity: Major
      Found in lib/controllers/websockets.js - About 2 hrs to fix

        Function tasksDetails has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const tasksDetails = function(fullDetails = false, reqQuery, userId, listId) {
          return new Promise((resolve, reject) => {
            const taskModel = {
              model: Task,
              attributes: ['id', 'updatedAt', 'createdAt']
        Severity: Minor
        Found in lib/controllers/helpers.js - About 1 hr to fix

          Function updateSingle has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                    const updateSingle = function(model) {
                      return new Promise(function(resolve, reject) {
                        const newData = req.body.tasks[model.id]
                        if (
                          model.updatedAt.getTime() - UPDATE_THRESHOLD <
          Severity: Minor
          Found in lib/controllers/tasks.js - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                            if (req.body.order.indexOf(key) === -1) {
                              shouldUpdate = false
                            }
            Severity: Major
            Found in lib/controllers/tasks.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              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') {
              Severity: Major
              Found in lib/controllers/tasks.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                              if (shouldUpdate) {
                                payload.order = req.body.order
                              }
                Severity: Major
                Found in lib/controllers/tasks.js - About 45 mins to fix

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

                    const mapUserToGuid = async (username, createAccount = true) => {
                      let id = userCache.get(username)
                      if (id !== undefined) {
                        return id
                      }
                  Severity: Minor
                  Found in lib/middleware.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 tasksDetails has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const tasksDetails = function(fullDetails = false, reqQuery, userId, listId) {
                    return new Promise((resolve, reject) => {
                      const taskModel = {
                        model: Task,
                        attributes: ['id', 'updatedAt', 'createdAt']
                  Severity: Minor
                  Found in lib/controllers/helpers.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

                  Severity
                  Category
                  Status
                  Source
                  Language