nitrotasks/nitro-server

View on GitHub

Showing 36 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

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            Token.create({
              expires: new Date(),
              userId: user.get('id'),
              userAgent: req.headers['user-agent']
            }).then(function(token) {
    Severity: Major
    Found in lib/controllers/users.js and 1 other location - About 2 hrs to fix
    lib/controllers/authentication.js on lines 22..31

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 89.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            Token.create({
              expires: new Date(),
              userId: user.get('id'),
              userAgent: req.headers['user-agent'],
            }).then(function(token) {
    Severity: Major
    Found in lib/controllers/authentication.js and 1 other location - About 2 hrs to fix
    lib/controllers/users.js on lines 25..34

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 89.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

        Similar blocks of code found in 7 locations. Consider refactoring.
        Open

                  retrieved
                    .update({
                      order: newOrder
                    })
                    .then(function() {
        Severity: Major
        Found in lib/controllers/tasks.js and 6 other locations - About 1 hr to fix
        lib/controllers/tasks.js on lines 118..133
        lib/controllers/tasks.js on lines 76..151
        lib/controllers/tasks.js on lines 166..235
        lib/controllers/tasks.js on lines 311..339
        lib/controllers/tasks.js on lines 243..366
        lib/controllers/tasks.js on lines 373..453

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 73.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 7 locations. Consider refactoring.
        Open

                  Promise.all(promises)
                    .then(function(data) {
                      // set the update so the client can pick up on changes on this list
                      retrieved.changed('updatedAt', true)
                      retrieved
        Severity: Major
        Found in lib/controllers/tasks.js and 6 other locations - About 1 hr to fix
        lib/controllers/tasks.js on lines 118..133
        lib/controllers/tasks.js on lines 76..151
        lib/controllers/tasks.js on lines 166..235
        lib/controllers/tasks.js on lines 243..366
        lib/controllers/tasks.js on lines 400..426
        lib/controllers/tasks.js on lines 373..453

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 73.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 7 locations. Consider refactoring.
        Open

                  list
                    .update(payload)
                    .then(function(list) {
                      res.send(list)
                    })
        Severity: Major
        Found in lib/controllers/tasks.js and 6 other locations - About 1 hr to fix
        lib/controllers/tasks.js on lines 76..151
        lib/controllers/tasks.js on lines 166..235
        lib/controllers/tasks.js on lines 311..339
        lib/controllers/tasks.js on lines 243..366
        lib/controllers/tasks.js on lines 400..426
        lib/controllers/tasks.js on lines 373..453

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 73.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 7 locations. Consider refactoring.
        Open

          List.findById(req.params.listid, query)
            .then(function(list) {
              if (list) {
                // todo: proper validation?
                const adding = req.body.tasks.map(function(item) {
        Severity: Major
        Found in lib/controllers/tasks.js and 6 other locations - About 1 hr to fix
        lib/controllers/tasks.js on lines 118..133
        lib/controllers/tasks.js on lines 76..151
        lib/controllers/tasks.js on lines 311..339
        lib/controllers/tasks.js on lines 243..366
        lib/controllers/tasks.js on lines 400..426
        lib/controllers/tasks.js on lines 373..453

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 73.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 7 locations. Consider refactoring.
        Open

          List.findById(req.params.listid, query)
            .then(function(list) {
              if (list) {
                if (
                  list.updatedAt.getTime() - UPDATE_THRESHOLD <
        Severity: Major
        Found in lib/controllers/tasks.js and 6 other locations - About 1 hr to fix
        lib/controllers/tasks.js on lines 118..133
        lib/controllers/tasks.js on lines 166..235
        lib/controllers/tasks.js on lines 311..339
        lib/controllers/tasks.js on lines 243..366
        lib/controllers/tasks.js on lines 400..426
        lib/controllers/tasks.js on lines 373..453

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 73.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 7 locations. Consider refactoring.
        Open

            List.findById(req.params.listid, {
              include: [
                {
                  model: User,
                  attributes: ['id'],
        Severity: Major
        Found in lib/controllers/tasks.js and 6 other locations - About 1 hr to fix
        lib/controllers/tasks.js on lines 118..133
        lib/controllers/tasks.js on lines 76..151
        lib/controllers/tasks.js on lines 166..235
        lib/controllers/tasks.js on lines 311..339
        lib/controllers/tasks.js on lines 400..426
        lib/controllers/tasks.js on lines 373..453

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 73.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 7 locations. Consider refactoring.
        Open

            List.findById(req.params.listid, {
              attributes: ['id', 'order'],
              include: [
                {
                  model: User,
        Severity: Major
        Found in lib/controllers/tasks.js and 6 other locations - About 1 hr to fix
        lib/controllers/tasks.js on lines 118..133
        lib/controllers/tasks.js on lines 76..151
        lib/controllers/tasks.js on lines 166..235
        lib/controllers/tasks.js on lines 311..339
        lib/controllers/tasks.js on lines 243..366
        lib/controllers/tasks.js on lines 400..426

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 73.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                  if (retrieved) {
                    retrieved.tasks.forEach(function(item) {
                      const index = specifically.indexOf(item.id)
                      if (index > -1) {
                        specifically.splice(index, 1)
        Severity: Major
        Found in lib/controllers/tasks.js and 1 other location - About 1 hr to fix
        lib/controllers/tasks.js on lines 429..436

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 72.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                  if (retrieved) {
                    retrieved.tasks.forEach(function(item) {
                      const index = specifically.indexOf(item.id)
                      if (index > -1) {
                        specifically.splice(index, 1)
        Severity: Major
        Found in lib/controllers/tasks.js and 1 other location - About 1 hr to fix
        lib/controllers/tasks.js on lines 342..349

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 72.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

          tasksDetails(true, req.query, req.user, req.params.listid)
            .then(data => {
              res.send(data)
            })
            .catch(err => {
        Severity: Major
        Found in lib/controllers/tasks.js and 2 other locations - About 1 hr to fix
        lib/controllers/archivedtasks.js on lines 30..44
        lib/controllers/tasks.js on lines 18..35

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 71.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

          archiveTasks(tasks, req.user, req.params.listid)
            .then(tasks => {
              res.send({ message: 'Successfully archived tasks.', data: tasks })
            })
            .catch(err => {
        Severity: Major
        Found in lib/controllers/archivedtasks.js and 2 other locations - About 1 hr to fix
        lib/controllers/tasks.js on lines 18..35
        lib/controllers/tasks.js on lines 38..52

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 71.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

            tasksDetails(false, req.query, req.user, req.params.listid)
              .then(data => {
                if (typeof req.query.tasks !== 'undefined') {
                  return res.send(data.tasks)
                }
          Severity: Major
          Found in lib/controllers/tasks.js and 2 other locations - About 1 hr to fix
          lib/controllers/archivedtasks.js on lines 30..44
          lib/controllers/tasks.js on lines 38..52

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 71.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            const Meta = db.define('meta', {
              id: {
                primaryKey: true,
                type: Sequelize.UUID,
                defaultValue: Sequelize.UUIDV4
            Severity: Major
            Found in lib/models/meta.js and 1 other location - About 1 hr to fix
            lib/models/token.js on lines 6..14

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 64.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language