Emapic/emapic

View on GitHub

Showing 2,019 of 2,019 total issues

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

module.exports = function(app) {

    // Function for ordering the votes in descending order
    function orderVotesDesc(results) {
        var orderedVotes = {},
Severity: Major
Found in routes/utils_api.js - About 4 days to fix

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

    module.exports = function(sequelize, DataTypes) {
        var Survey = sequelize.define('Survey', {
            id: { type: DataTypes.BIGINT, autoIncrement: true, primaryKey: true },
            title: { type: DataTypes.STRING, allowNull: false },
            description: DataTypes.STRING,
    Severity: Major
    Found in models/survey.js - About 4 days to fix

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

      module.exports = function(app) {
          utils(app);
      
          var oauthConfig = nconf.get('app').oAuth;
      
      
      Severity: Major
      Found in routes/auth/index.js - About 4 days to fix

        Function exports has a Cognitive Complexity of 177 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = function(app) {
        
            // Function for ordering the votes in descending order
            function orderVotesDesc(results) {
                var orderedVotes = {},
        Severity: Minor
        Found in routes/utils_api.js - About 3 days 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

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

                            for (var l = 0, lLen = questions.length; l < lLen; l++) {
                                var ansId, ans;
                                switch (questions[l].type) {
                                    case 'list-radio':
                                        ans = ansId = parseInt(result['q' + questions[l].question_order + '.id'], 10);
        Severity: Major
        Found in routes/utils_api.js and 1 other location - About 2 days to fix
        routes/utils_api.js on lines 121..155

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

        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

                    for (var l = 0, lLen = questions.length; l < lLen; l++) {
                        var ansId, ans;
                        switch (questions[l].type) {
                            case 'list-radio':
                                ans = ansId = parseInt(result['q' + questions[l].question_order + '.id'], 10);
        Severity: Major
        Found in routes/utils_api.js and 1 other location - About 2 days to fix
        routes/utils_api.js on lines 714..748

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

        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 575 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function(app) {
        
            function handleInternalError(req, res) {
                return function(err) {
                    logger.error('Internal server error during API request: ' + err.message);
        Severity: Major
        Found in routes/api-engine_routes.js - About 2 days to fix

          File survey.js has 1037 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          var Promise = require('bluebird'),
              nconf = require('nconf'),
              htmlToText = require('html-to-text'),
              linkifyHtml = require('linkifyjs/html'),
              fsp = require('fs-extra'),
          Severity: Major
          Found in models/survey.js - About 2 days to fix

            Function exports has a Cognitive Complexity of 128 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports = function(app) {
                Utils = {
                    encryptSurveyId: function(id) {
                        return (id) ? bases.toBase(id * surveyIdEncr.factor, surveyIdEncr.base ) : null;
                    },
            Severity: Minor
            Found in utils.js - About 2 days 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 exports has a Cognitive Complexity of 115 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports = function(sequelize, DataTypes) {
                var Survey = sequelize.define('Survey', {
                    id: { type: DataTypes.BIGINT, autoIncrement: true, primaryKey: true },
                    title: { type: DataTypes.STRING, allowNull: false },
                    description: DataTypes.STRING,
            Severity: Minor
            Found in models/survey.js - About 2 days 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 utils_api.js has 898 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            var Promise = require('bluebird'),
                csv = Promise.promisifyAll(require('fast-csv')),
                moment = require('moment'),
                XLSX = require('excel4node'),
                sequelize = models.sequelize;
            Severity: Major
            Found in routes/utils_api.js - About 2 days to fix

              Function EmapicApp has 401 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              var EmapicApp = function() {
              
                  //  Scope.
                  var self = this,
                      serverConfig,
              Severity: Major
              Found in server.js - About 2 days to fix

                File index.js has 826 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                var passport = require('passport'),
                    LocalStrategy = require('passport-local').Strategy,
                    GoogleStrategy = require('passport-google-oauth').OAuth2Strategy,
                    FacebookStrategy = require('passport-facebook').Strategy,
                    RememberMeStrategy = require('passport-remember-me').Strategy,
                Severity: Major
                Found in routes/auth/index.js - About 1 day to fix

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

                              req.user.save().then(function(user) {
                                  if (isNull) {
                                      req.session.success = 'delete_user_position_success_msg';
                                      logger.info("Sucessfully deleted default position for user with mail " + user.email + " and id " + user.id);
                                  } else {
                  Severity: Major
                  Found in routes/auth/index.js and 1 other location - About 1 day to fix
                  routes/auth/index.js on lines 393..416

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

                  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

                              req.user.save().then(function(user) {
                                  if (isNull) {
                                      req.session.success = 'delete_avatar_success_msg';
                                      logger.info("Sucessfully deleted avatar for user with mail " + user.email + " and id " + user.id);
                                  } else {
                  Severity: Major
                  Found in routes/auth/index.js and 1 other location - About 1 day to fix
                  routes/auth/index.js on lines 430..453

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

                  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 generateTextInputQuestionHtml(question, validator, maxLength, placeholderText, req) {
                      var opt = req.i18n.__('optional_note'),
                          max = req.i18n.__('max_length_note'),
                          validator = validator || null,
                          mandatory = question.mandatory;
                  Severity: Major
                  Found in models/question.js and 1 other location - About 1 day to fix
                  models/question.js on lines 289..305

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

                  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 generateTextAreaQuestionHtml(question, validator, maxLength, placeholderText, req) {
                      var opt = req.i18n.__('optional_note'),
                          max = req.i18n.__('max_length_note'),
                          validator = validator || null,
                          mandatory = question.mandatory;
                  Severity: Major
                  Found in models/question.js and 1 other location - About 1 day to fix
                  models/question.js on lines 271..287

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

                  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 368 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports = function(sequelize, DataTypes) {
                      var Question = sequelize.define('Question', {
                          id: { type: DataTypes.BIGINT, autoIncrement: true, primaryKey: true },
                          type: { type: DataTypes.STRING, allowNull: false, defaultValue: 'text' },
                          title: { type: DataTypes.STRING, allowNull: false, defaultValue: '' },
                  Severity: Major
                  Found in models/question.js - About 1 day to fix

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

                        app.get('/api/survey/:surveyId/description', function(req, res) {
                            models.Survey.scope('includeAuthor').findByPk(Utils.decryptSurveyId(req.params.surveyId)).then(function(survey) {
                                if (survey === null) {
                                    return res.status(404).json({ error_code: 'invalid_resource', error: 'requested survey doesn\'t exist.' });
                                }
                    Severity: Major
                    Found in routes/api-engine_routes.js and 2 other locations - About 1 day to fix
                    routes/api-engine_routes.js on lines 246..266
                    routes/api-engine_routes.js on lines 325..345

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

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

                        app.get('/api/survey/:surveyId/totals', function(req, res) {
                            models.Survey.scope('includeAuthor').findByPk(Utils.decryptSurveyId(req.params.surveyId)).then(function(survey) {
                                if (survey === null) {
                                    return res.status(404).json({ error_code: 'invalid_resource', error: 'requested survey doesn\'t exist.' });
                                }
                    Severity: Major
                    Found in routes/api-engine_routes.js and 2 other locations - About 1 day to fix
                    routes/api-engine_routes.js on lines 167..187
                    routes/api-engine_routes.js on lines 325..345

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

                    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