appirio-tech/lc1-discussion-service

View on GitHub

Showing 48 of 73 total issues

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

        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

          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

            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

              Function parseOrderBy has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              exports.parseOrderBy = function(model, req, filters, orderParam) {
                if (!orderParam) {
                  routeHelper.addValidationError(req, 'Value of orderBy parameter is empty');
                  return;
                }
              Severity: Minor
              Found in lib/paramHelper.js - About 1 hr to fix

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

                module.exports = function(config) {
                  var fse = require('fs-extra');
                  var path = require('path');
                  var Sequelize = require('sequelize');
                  var _ = require('lodash');
                Severity: Minor
                Found in api/models/index.js - About 1 hr to fix

                  Function findRightBracket has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function findRightBracket(req, string) {
                    var count = 0;
                    for (var i = 0; i < string.length; i += 1) {
                      if (string[i] === ')') {
                        if (i === 0) {
                  Severity: Minor
                  Found in lib/partialResponseHelper.js - About 1 hr 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

                  Function parseOrderBy has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  exports.parseOrderBy = function(model, req, filters, orderParam) {
                    if (!orderParam) {
                      routeHelper.addValidationError(req, 'Value of orderBy parameter is empty');
                      return;
                    }
                  Severity: Minor
                  Found in lib/paramHelper.js - About 1 hr 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

                  Function _buildReferenceFilter has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function _buildReferenceFilter(referenceModels, req, callback) {
                    var filters = { where: {} };   // start with emtpty filter
                    if (!referenceModels) {
                      callback(null, filters);
                    } else {
                  Severity: Minor
                  Found in lib/controllerHelper.js - About 1 hr to fix

                    Function updateEntity has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function updateEntity(model, referenceModels, options, req, funcCallback) {
                      async.waterfall([
                        function(callback) {
                          _checkExtraParameters(req, callback);
                        },
                    Severity: Minor
                    Found in lib/controllerHelper.js - About 1 hr to fix

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

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

                        Function parseFilter has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        exports.parseFilter = function(model, req, filters, filterParam) {
                          if (!filterParam) {
                            routeHelper.addValidationError(req, 'Value of filter parameter is empty');
                            return;
                          }
                        Severity: Minor
                        Found in lib/paramHelper.js - About 1 hr to fix

                          Function tcUser has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          exports.tcUser = function(req, res, next) {
                            if (req.user) {
                              var options = {
                                url: config.get('app.tcUser') + '/user',
                                headers: {
                          Severity: Minor
                          Found in lib/tc-auth/tcUser.js - About 1 hr to fix

                            Function _setFilter has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function _setFilter(req, filters, operator, field, value) {
                              switch (operator) {
                                case '=': 
                                  var matched = value.match(/^in\s*\((.*)\)/);
                                  if (matched && matched.length === 2) { // in operator
                            Severity: Minor
                            Found in lib/paramHelper.js - About 1 hr to fix

                              Function renderJson has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              exports.renderJson = function(req, res) {
                                if (req.error) {
                                  if (req.error.errors) {   // validation errors
                                    res.status(req.error.code).json({
                                      result: {
                              Severity: Minor
                              Found in lib/routeHelper.js - About 1 hr to fix

                                Function _setFilter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                Open

                                function _setFilter(req, filters, operator, field, value) {
                                  switch (operator) {
                                    case '=': 
                                      var matched = value.match(/^in\s*\((.*)\)/);
                                      if (matched && matched.length === 2) { // in operator
                                Severity: Minor
                                Found in lib/paramHelper.js - About 1 hr 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

                                Function deleteEntity has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function deleteEntity(model, referenceModels, options, req, funcCallback) {
                                  async.waterfall([
                                    function(callback) {
                                      _checkExtraParameters(req, callback);
                                    },
                                Severity: Minor
                                Found in lib/controllerHelper.js - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language