appirio-tech/lc1-discussion-service

View on GitHub

Showing 73 of 73 total issues

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

        if(!_.isObject(Fields)){
          if(!subObject){
            callback(null);
            return;
          }
Severity: Major
Found in lib/partialResponseHelper.js and 1 other location - About 3 days to fix
lib/partialResponseHelper.js on lines 286..339

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

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(!_.isObject(Fields)){
      if(!subObject){
        callback(null);
        return;
      }
Severity: Major
Found in lib/partialResponseHelper.js and 1 other location - About 3 days to fix
lib/partialResponseHelper.js on lines 215..267

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

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

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

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

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

Refactorings

Further Reading

Function exports has 136 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(grunt) {
  var databaseUrl;

  var paths = {
    js: ['*.js', 'api/**/*.js', 'lib/*.js', '!test/coverage/**', '!bower_components/**', '!newrelic.js']
Severity: Major
Found in Gruntfile.js - About 5 hrs to fix

    Function recursionReduce has 134 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function recursionReduce(req, Model, Entity, Property, Fields, callback){
      var subObject = Entity[Property];
      if(_.isArray(subObject)){
    
        var tasks = [];
    Severity: Major
    Found in lib/partialResponseHelper.js - About 5 hrs to fix

      Function iterationParse has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

      function iterationParse(req, param, entity, property) {
        var subObject = null;
        if (!property) {
          subObject = entity;
        } else {
      Severity: Minor
      Found in lib/partialResponseHelper.js - About 4 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      File controllerHelper.js has 340 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /**
       * Copyright (c) 2014 TopCoder, Inc. All rights reserved.
       */
      /**
       * Helper methods for controller logic.
      Severity: Minor
      Found in lib/controllerHelper.js - About 4 hrs to fix

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

          if (config.has('app.pgURLWercker')) {
            postgresurl = config.get('app.pgURLWercker');
          } else if (config.has('app.pgURL')) {
            postgresurl = config.get('app.pgURL');
          } else {
        Severity: Major
        Found in api/models/index.js and 1 other location - About 4 hrs to fix
        Gruntfile.js on lines 22..32

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

        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 (envConfig.has('app.pgURLWercker')) {
            databaseUrl = envConfig.get('app.pgURLWercker');
          } else if (envConfig.has('app.pgURL')) {
            databaseUrl = envConfig.get('app.pgURL');
          } else {
        Severity: Major
        Found in Gruntfile.js and 1 other location - About 4 hrs to fix
        api/models/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 118.

        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

        File partialResponseHelper.js has 296 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /**
         * Copyright (c) 2014 TopCoder, Inc. All rights reserved.
         */
        /**
         * Helper methods for controller logic.
        Severity: Minor
        Found in lib/partialResponseHelper.js - About 3 hrs to fix

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

          function create(model, referenceModels, options, req, res, next) {
            createEntity(model, referenceModels, options, req, function(err, entity) {
              if (!err) {
                req.data = {
                  id: entity.id,
          Severity: Major
          Found in lib/controllerHelper.js and 1 other location - About 2 hrs to fix
          lib/controllerHelper.js on lines 401..414

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

          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 update(model, referenceModels, options, req, res, next) {
            updateEntity(model, referenceModels, options, req, function(err, entity) {
              if (!err) {
                req.data = {
                  id: entity.id,
          Severity: Major
          Found in lib/controllerHelper.js and 1 other location - About 2 hrs to fix
          lib/controllerHelper.js on lines 330..343

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

          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

              function(filters, callback) {
                // use entity filter IDs if configured
                if (options && options.entityFilterIDs) {
                  filters.where = _.omit(filters.where, function(value, key) {
                    return options.entityFilterIDs.indexOf(key) === -1;
          Severity: Major
          Found in lib/controllerHelper.js and 3 other locations - About 2 hrs to fix
          lib/controllerHelper.js on lines 189..198
          lib/controllerHelper.js on lines 361..369
          lib/controllerHelper.js on lines 432..440

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

          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

              function(filters, callback) {
                // use entity filter IDs if configured
                if (options && options.entityFilterIDs) {
                  filters.where = _.omit(filters.where, function(value, key) {
                    return options.entityFilterIDs.indexOf(key) === -1;
          Severity: Major
          Found in lib/controllerHelper.js and 3 other locations - About 2 hrs to fix
          lib/controllerHelper.js on lines 189..198
          lib/controllerHelper.js on lines 245..253
          lib/controllerHelper.js on lines 432..440

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

          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

              function(filters, callback) {
                // use entity filter IDs if configured
                if (options && options.entityFilterIDs) {
                  filters.where = _.omit(filters.where, function(value, key) {
                    return options.entityFilterIDs.indexOf(key) === -1;
          Severity: Major
          Found in lib/controllerHelper.js and 3 other locations - About 2 hrs to fix
          lib/controllerHelper.js on lines 189..198
          lib/controllerHelper.js on lines 245..253
          lib/controllerHelper.js on lines 361..369

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

          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

              function(filters, callback) {
                // use entity filter IDs if configured
                if (options && options.entityFilterIDs) {
                  filters.where = _.omit(filters.where, function(value, key) {
                    return options.entityFilterIDs.indexOf(key) === -1;
          Severity: Major
          Found in lib/controllerHelper.js and 3 other locations - About 2 hrs to fix
          lib/controllerHelper.js on lines 245..253
          lib/controllerHelper.js on lines 361..369
          lib/controllerHelper.js on lines 432..440

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

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

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

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

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

          Refactorings

          Further Reading

          Function iterationParse has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function iterationParse(req, param, entity, property) {
            var subObject = null;
            if (!property) {
              subObject = entity;
            } else {
          Severity: Major
          Found in lib/partialResponseHelper.js - About 2 hrs to fix

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

            var addErrorMessage = exports.addErrorMessage = function(req, errMsg, errCode) {
              req.error = {};
              req.error.message = errMsg;
              req.error.code = errCode || req.error.code || 500;
            };
            Severity: Major
            Found in lib/routeHelper.js and 1 other location - About 2 hrs to fix
            lib/routeHelper.js on lines 35..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 75.

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

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

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

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

            Refactorings

            Further Reading

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

            exports.addErrorMessage = function(req, errMsg, errCode) {
              req.error = {};
              req.error.message = errMsg;
              req.error.code = errCode || req.error.code || 500;
            };
            Severity: Major
            Found in lib/routeHelper.js and 1 other location - About 2 hrs to fix
            lib/routeHelper.js on lines 117..121

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

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

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

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

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

            Refactorings

            Further Reading

            Function exports has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function(sequelize, DataTypes) {
            
              var Message = sequelize.define('Message', {
                id: {
                  type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true,
            Severity: Minor
            Found in api/models/message.js - About 1 hr to fix

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

                ], function(err, totalCount, messages) {
                  if (!err) {
                    req.data = {
                      success: true,
                      status: 200,
              Severity: Major
              Found in api/controllers/messages.js and 2 other locations - About 1 hr to fix
              api/controllers/messages.js on lines 61..73
              lib/controllerHelper.js on lines 215..227

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

              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