540co/ads-bpa

View on GitHub
server/routes/reactions.js

Summary

Maintainability
F
3 days
Test Coverage

File reactions.js has 280 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var config = require('../config');
var express = require('express');
var async = require('async');

require('../models/service-manager.js');
Severity: Minor
Found in server/routes/reactions.js - About 2 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                if (reactionterm.definitionExists(definition)) {
                  err = new Error();
                  err.status = 422;
                  err.error = "Duplicate Definition Exists";
                  err.message = "Duplicate Definition Exists";
    Severity: Major
    Found in server/routes/reactions.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                if (!(vote === 'up' || vote === 'down')) {
                  err = new Error();
                  err.status = 400;
                  err.error = "Vote attribute '" + vote  + "' not valid";
                  err.message = "A vote attribute must be passed in body (ex. {'vote':'up'}) - valid values are 'up' or 'down'";
      Severity: Major
      Found in server/routes/reactions.js - About 45 mins to fix

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

                function(callback){
                  Reaction.getList(db.connection, response.meta.limit, response.meta.offset, function (data) {
                    response.data = data;
                    callback();
                  });
        Severity: Major
        Found in server/routes/reactions.js and 1 other location - About 1 hr to fix
        server/routes/searches.js on lines 108..113

        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

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

          if (!req.query.offset) {
            response.meta.offset = 0;
          } else {
            response.meta.offset = parseInt(req.query.offset);
          }
        Severity: Major
        Found in server/routes/reactions.js and 3 other locations - About 1 hr to fix
        server/routes/reactions.js on lines 20..20
        server/routes/searches.js on lines 75..75
        server/routes/searches.js on lines 85..89

        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 63.

        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 4 locations. Consider refactoring.
        Open

          if (!req.query.limit) {response.meta.limit = 25;} else {response.meta.limit = parseInt(req.query.limit);}
        Severity: Major
        Found in server/routes/reactions.js and 3 other locations - About 1 hr to fix
        server/routes/reactions.js on lines 30..34
        server/routes/searches.js on lines 75..75
        server/routes/searches.js on lines 85..89

        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 63.

        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 16 locations. Consider refactoring.
        Open

            if(req.headers['content-type'].indexOf("application/json") < 0) {
              err = new Error();
              err.status = 400;
              err.error = "Invalid content type";
              err.message = "Valid content type is 'application/json'";
        Severity: Major
        Found in server/routes/reactions.js and 15 other locations - About 55 mins to fix
        server/routes/reactions.js on lines 77..133
        server/routes/reactions.js on lines 85..132
        server/routes/reactions.js on lines 99..128
        server/routes/reactions.js on lines 106..125
        server/routes/reactions.js on lines 233..244
        server/routes/reactions.js on lines 259..332
        server/routes/reactions.js on lines 270..331
        server/routes/reactions.js on lines 279..329
        server/routes/reactions.js on lines 300..325
        server/routes/reactions.js on lines 307..323
        server/routes/reactions.js on lines 353..364
        server/routes/searches.js on lines 16..56
        server/routes/searches.js on lines 24..55
        server/routes/searches.js on lines 32..53
        server/routes/searches.js on lines 91..120

        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 54.

        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 16 locations. Consider refactoring.
        Open

                    if (reactionterm.definitionExists(definition)) {
                      err = new Error();
                      err.status = 422;
                      err.error = "Duplicate Definition Exists";
                      err.message = "Duplicate Definition Exists";
        Severity: Major
        Found in server/routes/reactions.js and 15 other locations - About 55 mins to fix
        server/routes/reactions.js on lines 77..133
        server/routes/reactions.js on lines 85..132
        server/routes/reactions.js on lines 99..128
        server/routes/reactions.js on lines 152..213
        server/routes/reactions.js on lines 233..244
        server/routes/reactions.js on lines 259..332
        server/routes/reactions.js on lines 270..331
        server/routes/reactions.js on lines 279..329
        server/routes/reactions.js on lines 300..325
        server/routes/reactions.js on lines 307..323
        server/routes/reactions.js on lines 353..364
        server/routes/searches.js on lines 16..56
        server/routes/searches.js on lines 24..55
        server/routes/searches.js on lines 32..53
        server/routes/searches.js on lines 91..120

        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 54.

        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 16 locations. Consider refactoring.
        Open

            if(reaction === null) {
              err = new Error();
              err.status = 404;
              err.error = "Reaction Not Found";
              err.message = "The reaction that you were looking for could not be found.";
        Severity: Major
        Found in server/routes/reactions.js and 15 other locations - About 55 mins to fix
        server/routes/reactions.js on lines 77..133
        server/routes/reactions.js on lines 85..132
        server/routes/reactions.js on lines 99..128
        server/routes/reactions.js on lines 106..125
        server/routes/reactions.js on lines 152..213
        server/routes/reactions.js on lines 259..332
        server/routes/reactions.js on lines 270..331
        server/routes/reactions.js on lines 279..329
        server/routes/reactions.js on lines 300..325
        server/routes/reactions.js on lines 307..323
        server/routes/reactions.js on lines 353..364
        server/routes/searches.js on lines 16..56
        server/routes/searches.js on lines 24..55
        server/routes/searches.js on lines 32..53
        server/routes/searches.js on lines 91..120

        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 54.

        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 16 locations. Consider refactoring.
        Open

            if(req.headers['content-type'].indexOf("application/json") < 0) {
              err = new Error();
              err.status = 400;
              err.error = "Invalid content type";
              err.message = "Valid content type is 'application/json'";
        Severity: Major
        Found in server/routes/reactions.js and 15 other locations - About 55 mins to fix
        server/routes/reactions.js on lines 85..132
        server/routes/reactions.js on lines 99..128
        server/routes/reactions.js on lines 106..125
        server/routes/reactions.js on lines 152..213
        server/routes/reactions.js on lines 233..244
        server/routes/reactions.js on lines 259..332
        server/routes/reactions.js on lines 270..331
        server/routes/reactions.js on lines 279..329
        server/routes/reactions.js on lines 300..325
        server/routes/reactions.js on lines 307..323
        server/routes/reactions.js on lines 353..364
        server/routes/searches.js on lines 16..56
        server/routes/searches.js on lines 24..55
        server/routes/searches.js on lines 32..53
        server/routes/searches.js on lines 91..120

        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 54.

        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 16 locations. Consider refactoring.
        Open

                if (!req.body.vote) {
                  err = new Error();
                  err.status = 400;
                  err.error = "Vote attribute not found in body";
                  err.message = "A vote attribute must be passed in body (ex. {'vote':'up'}) - valid values are 'up' or 'down'";
        Severity: Major
        Found in server/routes/reactions.js and 15 other locations - About 55 mins to fix
        server/routes/reactions.js on lines 77..133
        server/routes/reactions.js on lines 85..132
        server/routes/reactions.js on lines 99..128
        server/routes/reactions.js on lines 106..125
        server/routes/reactions.js on lines 152..213
        server/routes/reactions.js on lines 233..244
        server/routes/reactions.js on lines 259..332
        server/routes/reactions.js on lines 270..331
        server/routes/reactions.js on lines 300..325
        server/routes/reactions.js on lines 307..323
        server/routes/reactions.js on lines 353..364
        server/routes/searches.js on lines 16..56
        server/routes/searches.js on lines 24..55
        server/routes/searches.js on lines 32..53
        server/routes/searches.js on lines 91..120

        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 54.

        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 4 locations. Consider refactoring.
        Open

          if (req.headers['content-type']) {
            if(req.headers['content-type'].indexOf("application/json") < 0) {
              err = new Error();
              err.status = 400;
              err.error = "Invalid content type";
        Severity: Major
        Found in server/routes/reactions.js and 3 other locations - About 55 mins to fix
        server/routes/reactions.js on lines 151..220
        server/routes/reactions.js on lines 258..340
        server/routes/searches.js on lines 15..63

        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 54.

        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 4 locations. Consider refactoring.
        Open

                      reactionterm.upsert(db.connection, function (result) {
                        response.data = result;
                        response.calculateExecutionTime();
                        res.json(response);
                      });
        Severity: Major
        Found in server/routes/reactions.js and 3 other locations - About 55 mins to fix
        server/routes/reactions.js on lines 195..199
        server/routes/reactions.js on lines 317..321
        server/routes/searches.js on lines 46..50

        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 54.

        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 4 locations. Consider refactoring.
        Open

          if (req.headers['content-type']) {
            if(req.headers['content-type'].indexOf("application/json") < 0) {
              err = new Error();
              err.status = 400;
              err.error = "Invalid content type";
        Severity: Major
        Found in server/routes/reactions.js and 3 other locations - About 55 mins to fix
        server/routes/reactions.js on lines 76..140
        server/routes/reactions.js on lines 258..340
        server/routes/searches.js on lines 15..63

        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 54.

        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 16 locations. Consider refactoring.
        Open

              if (req.headers['content-type'].indexOf("application/json") < 0) {
                err = new Error();
                err.status = 400;
                err.error = "Invalid content type";
                err.message = "Valid content type is 'application/json'";
        Severity: Major
        Found in server/routes/reactions.js and 15 other locations - About 55 mins to fix
        server/routes/reactions.js on lines 77..133
        server/routes/reactions.js on lines 85..132
        server/routes/reactions.js on lines 99..128
        server/routes/reactions.js on lines 106..125
        server/routes/reactions.js on lines 152..213
        server/routes/reactions.js on lines 233..244
        server/routes/reactions.js on lines 259..332
        server/routes/reactions.js on lines 279..329
        server/routes/reactions.js on lines 300..325
        server/routes/reactions.js on lines 307..323
        server/routes/reactions.js on lines 353..364
        server/routes/searches.js on lines 16..56
        server/routes/searches.js on lines 24..55
        server/routes/searches.js on lines 32..53
        server/routes/searches.js on lines 91..120

        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 54.

        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 16 locations. Consider refactoring.
        Open

              if (!req.body.definition) {
                err = new Error();
                err.status = 400;
                err.error = "Definition attribute not found in body";
                err.message = "A definition value must be passed in body (ex. {'definition':'lorem ipsum'})";
        Severity: Major
        Found in server/routes/reactions.js and 15 other locations - About 55 mins to fix
        server/routes/reactions.js on lines 77..133
        server/routes/reactions.js on lines 99..128
        server/routes/reactions.js on lines 106..125
        server/routes/reactions.js on lines 152..213
        server/routes/reactions.js on lines 233..244
        server/routes/reactions.js on lines 259..332
        server/routes/reactions.js on lines 270..331
        server/routes/reactions.js on lines 279..329
        server/routes/reactions.js on lines 300..325
        server/routes/reactions.js on lines 307..323
        server/routes/reactions.js on lines 353..364
        server/routes/searches.js on lines 16..56
        server/routes/searches.js on lines 24..55
        server/routes/searches.js on lines 32..53
        server/routes/searches.js on lines 91..120

        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 54.

        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 16 locations. Consider refactoring.
        Open

                  if (!result) {
                    err = new Error();
                    err.status = 404;
                    err.error = "Reaction cannot be found";
                    err.message = "Reaction cannot be found";
        Severity: Major
        Found in server/routes/reactions.js and 15 other locations - About 55 mins to fix
        server/routes/reactions.js on lines 77..133
        server/routes/reactions.js on lines 85..132
        server/routes/reactions.js on lines 106..125
        server/routes/reactions.js on lines 152..213
        server/routes/reactions.js on lines 233..244
        server/routes/reactions.js on lines 259..332
        server/routes/reactions.js on lines 270..331
        server/routes/reactions.js on lines 279..329
        server/routes/reactions.js on lines 300..325
        server/routes/reactions.js on lines 307..323
        server/routes/reactions.js on lines 353..364
        server/routes/searches.js on lines 16..56
        server/routes/searches.js on lines 24..55
        server/routes/searches.js on lines 32..53
        server/routes/searches.js on lines 91..120

        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 54.

        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 16 locations. Consider refactoring.
        Open

           if(req.headers['content-type'].indexOf("application/json") < 0) {
             err = new Error();
             err.status = 400;
             err.error = "Invalid content type";
             err.message = "Valid content type is 'application/json'";
        Severity: Major
        Found in server/routes/reactions.js and 15 other locations - About 55 mins to fix
        server/routes/reactions.js on lines 77..133
        server/routes/reactions.js on lines 85..132
        server/routes/reactions.js on lines 99..128
        server/routes/reactions.js on lines 106..125
        server/routes/reactions.js on lines 152..213
        server/routes/reactions.js on lines 233..244
        server/routes/reactions.js on lines 270..331
        server/routes/reactions.js on lines 279..329
        server/routes/reactions.js on lines 300..325
        server/routes/reactions.js on lines 307..323
        server/routes/reactions.js on lines 353..364
        server/routes/searches.js on lines 16..56
        server/routes/searches.js on lines 24..55
        server/routes/searches.js on lines 32..53
        server/routes/searches.js on lines 91..120

        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 54.

        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 16 locations. Consider refactoring.
        Open

                        if (!reactionterm.definitionIndexExists(definitionIndex)) {
                          err = new Error();
                          err.status = 404;
                          err.error = "Definition at that index does not exist";
                          err.message = "The definition at that index does not exist";
        Severity: Major
        Found in server/routes/reactions.js and 15 other locations - About 55 mins to fix
        server/routes/reactions.js on lines 77..133
        server/routes/reactions.js on lines 85..132
        server/routes/reactions.js on lines 99..128
        server/routes/reactions.js on lines 106..125
        server/routes/reactions.js on lines 152..213
        server/routes/reactions.js on lines 233..244
        server/routes/reactions.js on lines 259..332
        server/routes/reactions.js on lines 270..331
        server/routes/reactions.js on lines 279..329
        server/routes/reactions.js on lines 300..325
        server/routes/reactions.js on lines 353..364
        server/routes/searches.js on lines 16..56
        server/routes/searches.js on lines 24..55
        server/routes/searches.js on lines 32..53
        server/routes/searches.js on lines 91..120

        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 54.

        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 4 locations. Consider refactoring.
        Open

                      reactionterm.upsert(db.connection, function (result) {
                        response.data = result;
                        response.calculateExecutionTime();
                        res.json(response);
                      });
        Severity: Major
        Found in server/routes/reactions.js and 3 other locations - About 55 mins to fix
        server/routes/reactions.js on lines 120..124
        server/routes/reactions.js on lines 317..321
        server/routes/searches.js on lines 46..50

        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 54.

        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 4 locations. Consider refactoring.
        Open

                          reactionterm.upsert(db.connection, function (result) {
                            response.data = result;
                            response.calculateExecutionTime();
                            res.json(response);
                          });
        Severity: Major
        Found in server/routes/reactions.js and 3 other locations - About 55 mins to fix
        server/routes/reactions.js on lines 120..124
        server/routes/reactions.js on lines 195..199
        server/routes/searches.js on lines 46..50

        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 54.

        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 4 locations. Consider refactoring.
        Open

          if (req.headers['content-type']) {
           if(req.headers['content-type'].indexOf("application/json") < 0) {
             err = new Error();
             err.status = 400;
             err.error = "Invalid content type";
        Severity: Major
        Found in server/routes/reactions.js and 3 other locations - About 55 mins to fix
        server/routes/reactions.js on lines 76..140
        server/routes/reactions.js on lines 151..220
        server/routes/searches.js on lines 15..63

        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 54.

        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 16 locations. Consider refactoring.
        Open

                      if(reaction === null) {
                        err = new Error();
                        err.status = 404;
                        err.error = "Reaction Not Found";
                        err.message = "The reaction that you were looking for could not be found.";
        Severity: Major
        Found in server/routes/reactions.js and 15 other locations - About 55 mins to fix
        server/routes/reactions.js on lines 77..133
        server/routes/reactions.js on lines 85..132
        server/routes/reactions.js on lines 99..128
        server/routes/reactions.js on lines 106..125
        server/routes/reactions.js on lines 152..213
        server/routes/reactions.js on lines 233..244
        server/routes/reactions.js on lines 259..332
        server/routes/reactions.js on lines 270..331
        server/routes/reactions.js on lines 279..329
        server/routes/reactions.js on lines 307..323
        server/routes/reactions.js on lines 353..364
        server/routes/searches.js on lines 16..56
        server/routes/searches.js on lines 24..55
        server/routes/searches.js on lines 32..53
        server/routes/searches.js on lines 91..120

        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 54.

        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 16 locations. Consider refactoring.
        Open

            if(reaction === null) {
              err = new Error();
              err.status = 404;
              err.error = "Reaction Not Found";
              err.message = "The reaction that you were looking for could not be found.";
        Severity: Major
        Found in server/routes/reactions.js and 15 other locations - About 55 mins to fix
        server/routes/reactions.js on lines 77..133
        server/routes/reactions.js on lines 85..132
        server/routes/reactions.js on lines 99..128
        server/routes/reactions.js on lines 106..125
        server/routes/reactions.js on lines 152..213
        server/routes/reactions.js on lines 233..244
        server/routes/reactions.js on lines 259..332
        server/routes/reactions.js on lines 270..331
        server/routes/reactions.js on lines 279..329
        server/routes/reactions.js on lines 300..325
        server/routes/reactions.js on lines 307..323
        server/routes/searches.js on lines 16..56
        server/routes/searches.js on lines 24..55
        server/routes/searches.js on lines 32..53
        server/routes/searches.js on lines 91..120

        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 54.

        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 2 locations. Consider refactoring.
        Open

                      function(callback){
                        serviceManager.getDefinitionsFromWordnikApi(reactionterm.reaction, config.wordnikapi_key, function (result) {
                          reactionterm.addDefinition(result);
                          callback();
                        });
        Severity: Minor
        Found in server/routes/reactions.js and 1 other location - About 50 mins to fix
        server/routes/reactions.js on lines 180..185

        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 51.

        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 2 locations. Consider refactoring.
        Open

                      function(callback){
                        serviceManager.getDefinitionsFromDictionaryApi(reactionterm.reaction, config.dictionaryapi_key, function (result) {
                          reactionterm.addDefinition(result);
                          callback();
                        });
        Severity: Minor
        Found in server/routes/reactions.js and 1 other location - About 50 mins to fix
        server/routes/reactions.js on lines 186..191

        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 51.

        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 2 locations. Consider refactoring.
        Open

                function(callback){
                  Reaction.getCount(db.connection, function (count) {
                    response.meta.total_count = count;
                    callback();
                  });
        Severity: Minor
        Found in server/routes/reactions.js and 1 other location - About 35 mins to fix
        server/routes/searches.js on lines 102..107

        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 47.

        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

        There are no issues that match your filters.

        Category
        Status