540co/ads-bpa

View on GitHub

Showing 168 of 168 total issues

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 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 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.search) {
          err = new Error();
          err.status = 400;
          err.error = "A search attribute was not found in the body";
          err.message = "A search key/value must be passed in body (ex. {'search':'ibuprofen'})";
Severity: Major
Found in server/routes/searches.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/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 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 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/searches.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/reactions.js on lines 258..340

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

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/searches.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/reactions.js on lines 353..364
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 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 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(response.meta.offset < 0) {
    err = new Error();
    err.status = 404;
    err.error = "No searches can be found";
    err.message = "Bad offset query parameter - offset must be > 0";
Severity: Major
Found in server/routes/searches.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/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

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

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

Severity
Category
Status
Source
Language