Emapic/emapic

View on GitHub

Showing 122 of 2,019 total issues

Avoid deeply nested control flow statements.
Open

                            if (ansId === questions[l].Answers[n].sortorder) {
                                ans = questions[l].Answers[n].answer;
                            }
Severity: Major
Found in routes/utils_api.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                                if (ansId === questions[j].Answers[l].sortorder) {
                                    ans = questions[j].Answers[l].answer;
                                    break;
                                }
    Severity: Major
    Found in routes/utils_api.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if (isNaN(q)) {
                                  continue;
                              }
      Severity: Major
      Found in models/survey.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                    if ((answer.sortorder === -1) && (('q' + questions[j].question_order + '.value') in results[i])) {
                                        value = answer.answer + ' (' + results[i]['q' + questions[j].question_order + '.value'] + ')';
                                    } else {
                                        value = answer.answer;
                                    }
        Severity: Major
        Found in routes/utils_api.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (req.files['img_' + i + '_' + j].size > 2000000) {
                                      return Promise.reject({
                                          message: "invalid image for question nr " + i + " answer nr " + j + ": image file exceeds the 2MB max size.",
                                          code: 'answer_img_too_big'
                                      });
          Severity: Major
          Found in models/question.js - About 45 mins to fix

            Consider simplifying this complex logical expression.
            Open

                            } else if (err && err.name === 'SequelizeUniqueConstraintError' &&
                                ((err.errors && err.errors.constructor === Array && err.errors[0].path === 'login') ||
                                (err.message.indexOf('users_login_key') > -1))) {
                                req.session.error = 'username_duplicated_error_msg';
                                logger.debug('Login already in use: ' + err);
            Severity: Major
            Found in routes/auth/index.js - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                              if (err && err.name === 'SequelizeUniqueConstraintError' &&
                                  ((err.errors && err.errors.constructor === Array && err.errors[0].path === 'email') ||
                                  (err.message.indexOf('users_email_key') > -1))) {
                                  req.session.error = 'email_duplicated_error_msg';
                                  logger.debug('E-mail already exists: ' + err);
              Severity: Major
              Found in routes/auth/index.js - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                                if (err && err.name === 'SequelizeUniqueConstraintError' &&
                                    ((err.errors && err.errors.constructor === Array && err.errors[0].path === 'login') ||
                                    (err.message.indexOf('users_login_key') > -1))) {
                                    user.login = originalLogin;
                                    return nextLoginUserSignup(user, tryNr + 1);
                Severity: Major
                Found in routes/auth/index.js - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                                  if (err && err.name === 'SequelizeUniqueConstraintError' &&
                                      ((err.errors && err.errors.constructor === Array && err.errors[0].path === 'login') ||
                                      (err.message.indexOf('users_login_key') > -1))) {
                                      req.session.error = 'username_duplicated_error_msg';
                                      logger.debug('Login already in use: ' + err);
                  Severity: Major
                  Found in routes/auth/index.js - About 40 mins to fix

                    Function getPaginationHtml has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            getPaginationHtml: function(req, pageNr, pageSize, totalResults, elementName) {
                    Severity: Minor
                    Found in utils.js - About 35 mins to fix

                      Function generateTextInputQuestionHtml has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      function generateTextInputQuestionHtml(question, validator, maxLength, placeholderText, req) {
                      Severity: Minor
                      Found in models/question.js - About 35 mins to fix

                        Function transformImageSharp has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        function transformImageSharp(input, width, height, upscale, format) {
                        Severity: Minor
                        Found in utils.js - About 35 mins to fix

                          Function generateTextAreaQuestionHtml has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          function generateTextAreaQuestionHtml(question, validator, maxLength, placeholderText, req) {
                          Severity: Minor
                          Found in models/question.js - About 35 mins to fix

                            Function transformImageJimp has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            function transformImageJimp(input, width, height, upscale, format) {
                            Severity: Minor
                            Found in utils.js - About 35 mins to fix

                              Function generateTextInputQuestionHtml has a Cognitive Complexity of 7 (exceeds 5 allowed). 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: Minor
                              Found in models/question.js - About 35 mins 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

                              Avoid too many return statements within this function.
                              Open

                                                              return Promise.reject({
                                                                  message: "invalid answer for question nr " + question.question_order + " : selected file is not an image.",
                                                                  status: 400,
                                                                  code: 'invalid_request'
                                                              });
                              Severity: Major
                              Found in models/question.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                                            return Promise.resolve();
                                Severity: Major
                                Found in models/question.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                                          return Promise.resolve();
                                  Severity: Major
                                  Found in models/question.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                                    return Promise.reject({
                                                                        message: "invalid answer for question nr " + question.question_order + " : image file exceeds the 10MB max size.",
                                                                        status: 400,
                                                                        code: 'invalid_request'
                                                                    });
                                    Severity: Major
                                    Found in models/question.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                              return Utils.checkUrlIsImage(responses['q' + question.question_order + '.value']);
                                      Severity: Major
                                      Found in models/question.js - About 30 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language