DemocracyOS/democracyos

View on GitHub

Showing 269 of 430 total issues

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

      neutral: new Array(parseInt(topic.action.results.find((o) => o.value === 'neutral').percentage * topic.action.count)) || []
Severity: Major
Found in lib/site/topic-layout/topic-article/vote/component.js and 2 other locations - About 1 hr to fix
lib/site/topic-layout/topic-article/vote/component.js on lines 44..44
lib/site/topic-layout/topic-article/vote/component.js on lines 45..45

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

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

    if (!comment.author.equals(user._id)) {
      const err = new Error('Can\'t delete comments from other users')
      err.code = 'NOT_YOURS'
      err.status = 400
      throw err
Severity: Major
Found in lib/api-v2/db-api/comments/index.js and 1 other location - About 1 hr to fix
lib/api-v2/db-api/comments/index.js on lines 309..314

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

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 verifyAutoUnflag (user, comment) {
  if (comment.author.equals(user._id)) {
    const err = new Error('A user can\'t flag his own comment.')
    err.code = 'NO_AUTO_FLAG'
    throw err
Severity: Major
Found in lib/api-v2/db-api/comments/index.js and 1 other location - About 1 hr to fix
lib/api-v2/db-api/comments/index.js on lines 372..379

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

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

  dbReady()
    .then(() => Topic.collection.find({}).toArray())
    .then(mapPromises(function (topic) {
      if (!topic.action || !Object.keys(topic.action).includes('box')) return Promise.resolve(0)
      const newVotes = topic.action.box.map((vote) => {
Severity: Major
Found in migrations/1503256241267-update-topic-votes.js and 10 other locations - About 1 hr to fix
migrations/1487112733700-update-users-maxlengths.js on lines 15..57
migrations/1487112733702-update-topic-maxlengths.js on lines 16..66
migrations/1487113137271-add-topic-owner.js on lines 59..74
migrations/1487786060173-update-topic-action.js on lines 10..30
migrations/1487786060173-update-topic-action.js on lines 38..59
migrations/1495224425289-add-participant-count.js on lines 9..24
migrations/1495224425289-add-participant-count.js on lines 32..47
migrations/1501737026342-update-topic-box.js on lines 32..82
migrations/1501737026342-update-topic-box.js on lines 90..124
migrations/1503256241267-update-topic-votes.js on lines 47..66

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

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

  dbReady()
    .then(() => Topic.collection.find({}).toArray())
    .then(mapPromises(function (topic) {
      return Vote.find({ topic: topic._id })
        .then((votes) => votes.map((v) => ({ value: v.value, author: v.author, createdAt: v.createdAt })))
Severity: Major
Found in migrations/1503256241267-update-topic-votes.js and 10 other locations - About 1 hr to fix
migrations/1487112733700-update-users-maxlengths.js on lines 15..57
migrations/1487112733702-update-topic-maxlengths.js on lines 16..66
migrations/1487113137271-add-topic-owner.js on lines 59..74
migrations/1487786060173-update-topic-action.js on lines 10..30
migrations/1487786060173-update-topic-action.js on lines 38..59
migrations/1495224425289-add-participant-count.js on lines 9..24
migrations/1495224425289-add-participant-count.js on lines 32..47
migrations/1501737026342-update-topic-box.js on lines 32..82
migrations/1501737026342-update-topic-box.js on lines 90..124
migrations/1503256241267-update-topic-votes.js on lines 11..39

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

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

    batch.end(function (err, whitelists) {
      if (err) {
        log('Found error %s', err)
        return fn(err)
      }
Severity: Major
Found in lib/db-api/whitelist.js and 1 other location - About 1 hr to fix
lib/db-api/forum.js on lines 44..52

Duplicated Code

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

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

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

Tuning

This issue has a mass of 61.

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

  dbReady()
    .then(() => Topic.collection
      .find({})
      .toArray()
      .then(mapPromises(function (topic) {
Severity: Major
Found in migrations/1487112733702-update-topic-maxlengths.js and 10 other locations - About 1 hr to fix
migrations/1487112733700-update-users-maxlengths.js on lines 15..57
migrations/1487113137271-add-topic-owner.js on lines 59..74
migrations/1487786060173-update-topic-action.js on lines 10..30
migrations/1487786060173-update-topic-action.js on lines 38..59
migrations/1495224425289-add-participant-count.js on lines 9..24
migrations/1495224425289-add-participant-count.js on lines 32..47
migrations/1501737026342-update-topic-box.js on lines 32..82
migrations/1501737026342-update-topic-box.js on lines 90..124
migrations/1503256241267-update-topic-votes.js on lines 11..39
migrations/1503256241267-update-topic-votes.js on lines 47..66

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

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

  modelsReady()
    .then(() => Topic.collection.find({}).toArray())
    .then(mapPromises(function (topic) {
      if (!topic.owner) return Promise.resolve(0)

Severity: Major
Found in migrations/1487113137271-add-topic-owner.js and 10 other locations - About 1 hr to fix
migrations/1487112733700-update-users-maxlengths.js on lines 15..57
migrations/1487112733702-update-topic-maxlengths.js on lines 16..66
migrations/1487786060173-update-topic-action.js on lines 10..30
migrations/1487786060173-update-topic-action.js on lines 38..59
migrations/1495224425289-add-participant-count.js on lines 9..24
migrations/1495224425289-add-participant-count.js on lines 32..47
migrations/1501737026342-update-topic-box.js on lines 32..82
migrations/1501737026342-update-topic-box.js on lines 90..124
migrations/1503256241267-update-topic-votes.js on lines 11..39
migrations/1503256241267-update-topic-votes.js on lines 47..66

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

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 renderLayout (req, res) {
  var locale = req.locale

  res.render(html, {
    config: config,
Severity: Major
Found in lib/admin/layout/index.js and 1 other location - About 1 hr to fix
lib/layout/index.js on lines 21..31

Duplicated Code

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

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

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

Tuning

This issue has a mass of 61.

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

  return function _renderLayout (req, res) {
    var locale = req.locale

    res.render(template, {
      config: config,
Severity: Major
Found in lib/layout/index.js and 1 other location - About 1 hr to fix
lib/admin/layout/index.js on lines 13..23

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

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

  dbReady()
    .then(() => Topic.collection.find({}).toArray())
    .then(mapPromises(function (topic) {
      const action = {}
      action.method = topic.votable ? 'vote' : ''
Severity: Major
Found in migrations/1487786060173-update-topic-action.js and 10 other locations - About 1 hr to fix
migrations/1487112733700-update-users-maxlengths.js on lines 15..57
migrations/1487112733702-update-topic-maxlengths.js on lines 16..66
migrations/1487113137271-add-topic-owner.js on lines 59..74
migrations/1487786060173-update-topic-action.js on lines 38..59
migrations/1495224425289-add-participant-count.js on lines 9..24
migrations/1495224425289-add-participant-count.js on lines 32..47
migrations/1501737026342-update-topic-box.js on lines 32..82
migrations/1501737026342-update-topic-box.js on lines 90..124
migrations/1503256241267-update-topic-votes.js on lines 11..39
migrations/1503256241267-update-topic-votes.js on lines 47..66

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

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

  dbReady()
    .then(() => Topic.collection.find({}).toArray())
    .then(mapPromises(function (topic) {
      if (!topic.action || !Object.keys(topic.action).includes('box')) return Promise.resolve(0)
      const action = {
Severity: Major
Found in migrations/1501737026342-update-topic-box.js and 10 other locations - About 1 hr to fix
migrations/1487112733700-update-users-maxlengths.js on lines 15..57
migrations/1487112733702-update-topic-maxlengths.js on lines 16..66
migrations/1487113137271-add-topic-owner.js on lines 59..74
migrations/1487786060173-update-topic-action.js on lines 10..30
migrations/1487786060173-update-topic-action.js on lines 38..59
migrations/1495224425289-add-participant-count.js on lines 9..24
migrations/1495224425289-add-participant-count.js on lines 32..47
migrations/1501737026342-update-topic-box.js on lines 32..82
migrations/1503256241267-update-topic-votes.js on lines 11..39
migrations/1503256241267-update-topic-votes.js on lines 47..66

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

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 verifyAutoFlag (user, comment) {
  if (comment.author.equals(user._id)) {
    const err = new Error('A user can\'t flag his own comment.')
    err.code = 'NO_AUTO_FLAG'
    throw err
Severity: Major
Found in lib/api-v2/db-api/comments/index.js and 1 other location - About 1 hr to fix
lib/api-v2/db-api/comments/index.js on lines 413..420

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

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

  dbReady()
    .then(() => Topic.collection.find({}).toArray())
    .then(mapPromises(function (topic) {
      const count = (topic.participants && topic.participants.length > 0) ? topic.participants.length : 0

Severity: Major
Found in migrations/1495224425289-add-participant-count.js and 10 other locations - About 1 hr to fix
migrations/1487112733700-update-users-maxlengths.js on lines 15..57
migrations/1487112733702-update-topic-maxlengths.js on lines 16..66
migrations/1487113137271-add-topic-owner.js on lines 59..74
migrations/1487786060173-update-topic-action.js on lines 10..30
migrations/1487786060173-update-topic-action.js on lines 38..59
migrations/1495224425289-add-participant-count.js on lines 32..47
migrations/1501737026342-update-topic-box.js on lines 32..82
migrations/1501737026342-update-topic-box.js on lines 90..124
migrations/1503256241267-update-topic-votes.js on lines 11..39
migrations/1503256241267-update-topic-votes.js on lines 47..66

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

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

  query.exec(function (err, forums) {
    if (err) {
      log('Found error %j', err)
      return fn(err)
    }
Severity: Major
Found in lib/db-api/forum.js and 1 other location - About 1 hr to fix
lib/db-api/whitelist.js on lines 119..127

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

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

  dbReady()
    .then(function () {
      return Topic.collection
        .find({})
        .toArray()
Severity: Major
Found in migrations/1495224425289-add-participant-count.js and 10 other locations - About 1 hr to fix
migrations/1487112733700-update-users-maxlengths.js on lines 15..57
migrations/1487112733702-update-topic-maxlengths.js on lines 16..66
migrations/1487113137271-add-topic-owner.js on lines 59..74
migrations/1487786060173-update-topic-action.js on lines 10..30
migrations/1487786060173-update-topic-action.js on lines 38..59
migrations/1495224425289-add-participant-count.js on lines 9..24
migrations/1501737026342-update-topic-box.js on lines 32..82
migrations/1501737026342-update-topic-box.js on lines 90..124
migrations/1503256241267-update-topic-votes.js on lines 11..39
migrations/1503256241267-update-topic-votes.js on lines 47..66

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

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

    if (!reply.author.equals(user.id)) {
      const err = new Error('Can\'t delete replies from other users')
      err.code = 'NOT_YOURS'
      err.status = 400
      throw err
Severity: Major
Found in lib/api-v2/db-api/comments/index.js and 1 other location - About 1 hr to fix
lib/api-v2/db-api/comments/index.js on lines 247..252

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

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

  dbReady()
    .then(() => User.collection
      .find({})
      .toArray()
      .then(mapPromises(function (user) {
Severity: Major
Found in migrations/1487112733700-update-users-maxlengths.js and 10 other locations - About 1 hr to fix
migrations/1487112733702-update-topic-maxlengths.js on lines 16..66
migrations/1487113137271-add-topic-owner.js on lines 59..74
migrations/1487786060173-update-topic-action.js on lines 10..30
migrations/1487786060173-update-topic-action.js on lines 38..59
migrations/1495224425289-add-participant-count.js on lines 9..24
migrations/1495224425289-add-participant-count.js on lines 32..47
migrations/1501737026342-update-topic-box.js on lines 32..82
migrations/1501737026342-update-topic-box.js on lines 90..124
migrations/1503256241267-update-topic-votes.js on lines 11..39
migrations/1503256241267-update-topic-votes.js on lines 47..66

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

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

  dbReady()
    .then(() => Topic.collection.find({}).toArray())
    .then(mapPromises(function (topic) {
      if (topic.action && Object.keys(topic.action).includes('box')) return Promise.resolve(0)
      const action = {
Severity: Major
Found in migrations/1501737026342-update-topic-box.js and 10 other locations - About 1 hr to fix
migrations/1487112733700-update-users-maxlengths.js on lines 15..57
migrations/1487112733702-update-topic-maxlengths.js on lines 16..66
migrations/1487113137271-add-topic-owner.js on lines 59..74
migrations/1487786060173-update-topic-action.js on lines 10..30
migrations/1487786060173-update-topic-action.js on lines 38..59
migrations/1495224425289-add-participant-count.js on lines 9..24
migrations/1495224425289-add-participant-count.js on lines 32..47
migrations/1501737026342-update-topic-box.js on lines 90..124
migrations/1503256241267-update-topic-votes.js on lines 11..39
migrations/1503256241267-update-topic-votes.js on lines 47..66

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

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

  dbReady()
    .then(function () {
      return Topic.collection
        .find({})
        .toArray()
Severity: Major
Found in migrations/1487786060173-update-topic-action.js and 10 other locations - About 1 hr to fix
migrations/1487112733700-update-users-maxlengths.js on lines 15..57
migrations/1487112733702-update-topic-maxlengths.js on lines 16..66
migrations/1487113137271-add-topic-owner.js on lines 59..74
migrations/1487786060173-update-topic-action.js on lines 10..30
migrations/1495224425289-add-participant-count.js on lines 9..24
migrations/1495224425289-add-participant-count.js on lines 32..47
migrations/1501737026342-update-topic-box.js on lines 32..82
migrations/1501737026342-update-topic-box.js on lines 90..124
migrations/1503256241267-update-topic-votes.js on lines 11..39
migrations/1503256241267-update-topic-votes.js on lines 47..66

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

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