pinclub/pinclub

View on GitHub
api/v1/reply.js

Summary

Maintainability
C
1 day
Test Coverage

Function create has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var create = function (req, res, next) {
  var topic = req.params.topic;
  var content  = req.body.content || '';
  var reply_id = req.body.reply_id;

Severity: Major
Found in api/v1/reply.js - About 2 hrs to fix

    Function ups has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var ups = function (req, res, next) {
      var replyId = req.params.reply_id;
      var userId  = req.user.id;
    
      if (!validator.isMongoId(replyId)) {
    Severity: Minor
    Found in api/v1/reply.js - About 1 hr to fix

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

          if (reply.author.equals(userId) && !config.debug) {
            res.status(403);
            return res.send({success: false, error_msg: '不能帮自己点赞'});
          } else {
            var action;
      Severity: Major
      Found in api/v1/reply.js and 1 other location - About 5 hrs to fix
      controllers/reply.js on lines 165..188

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

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

        if (!validator.isMongoId(topic)) {
          res.status(400);
          return res.send({success: false, error_msg: '不是有效的话题id'});
        }
      Severity: Major
      Found in api/v1/reply.js and 9 other locations - About 45 mins to fix
      api/v1/reply.js on lines 84..87
      api/v1/topic.js on lines 114..117
      api/v1/topic_collect.js on lines 55..58
      api/v1/topic_collect.js on lines 103..106
      api/v2/board.js on lines 63..66
      api/v2/board.js on lines 170..173
      api/v2/board.js on lines 230..233
      api/v2/image.js on lines 446..449
      api/v2/topic.js on lines 193..196

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

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

        if (!validator.isMongoId(replyId)) {
          res.status(400);
          return res.send({success: false, error_msg: '不是有效的评论id'});
        }
      Severity: Major
      Found in api/v1/reply.js and 9 other locations - About 45 mins to fix
      api/v1/reply.js on lines 24..27
      api/v1/topic.js on lines 114..117
      api/v1/topic_collect.js on lines 55..58
      api/v1/topic_collect.js on lines 103..106
      api/v2/board.js on lines 63..66
      api/v2/board.js on lines 170..173
      api/v2/board.js on lines 230..233
      api/v2/image.js on lines 446..449
      api/v2/topic.js on lines 193..196

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

      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