openmrs/openmrs-contrib-id

View on GitHub

Showing 35 of 41 total issues

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

validate.chkEmailInvalidOrDup = (email, callback) => {
  validate.chkEmailInvalid(email, (err, result) => {
    if (err) {
      return callback(err);
    }
Severity: Minor
Found in app/validate.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 restrictTo has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

exports.restrictTo = role => (req, res, next) => {
  const fail = () => {
    req.flash('error', 'You are not authorized to access this resource.');
    if (req.session.user) {
      if (req.originalUrl === '/') {
Severity: Minor
Found in app/express-middleware.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 exports has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

exports = module.exports = app => {


  // AJAX
  app.post('/password', mid.forceLogin,
Severity: Minor
Found in app/routes/profile/password.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 exports has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports = module.exports = (err, req, res, next) => {
  const trackId = uuid.v4();
  log.error(`ID: ${trackId}`);
  log.error(`Caught error: ${err.name}`);
  log.error(err.message);
Severity: Minor
Found in app/routes/error.js - About 1 hr to fix

    Function syncFormageUser has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function syncFormageUser(user, callback) {
    
      return FormageUser.findOne({
          username: user.username
        }).exec()
    Severity: Minor
    Found in app/db-admin/syncAdminUsers.js - About 1 hr to fix

      Function unscrambleFields has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        unscrambleFields: function unscrambleFields(req, res, next) {
          // Parse through the body and unscramble any fields.
      
          // Fail the request if no spinner was passed
          if (!req.body.spinner) {
      Severity: Minor
      Found in app/routes/signup/botproof.js - About 1 hr to fix

        Function enableUser has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        exports.enableUser = (username, cb) => {
          // find the user
          const search = next => {
            searchRaw(username, 'pwdAccountLockedTime', (err, user) => {
              if (err) {
        Severity: Minor
        Found in app/ldap.js - About 1 hr to fix

          Function lockoutUser has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.lockoutUser = (username, cb) => {
            // find the user
            const search = next => {
              searchRaw(username, 'pwdAccountLockedTime', (err, user) => {
                if (err) {
          Severity: Minor
          Found in app/ldap.js - About 1 hr to fix

            Function checkBlacklist has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  function checkBlacklist(isWhite, cb) {
                    if (isWhite) {
                      return next();
                    }
                    async.map(Object.keys(spams), (list, cb) => {
            Severity: Minor
            Found in app/routes/signup/botproof.js - About 1 hr to fix

              Function findAndSync has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              const findAndSync = (filter, callback) => {
              
                const findMongo = cb => {
                  User.findOne(filter, (err, user) => {
                    if (err) {
              Severity: Minor
              Found in app/models/user.js - About 55 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

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

              exports = module.exports = (err, req, res, next) => {
                const trackId = uuid.v4();
                log.error(`ID: ${trackId}`);
                log.error(`Caught error: ${err.name}`);
                log.error(err.message);
              Severity: Minor
              Found in app/routes/error.js - About 55 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

              Function unscrambleFields has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                unscrambleFields: function unscrambleFields(req, res, next) {
                  // Parse through the body and unscramble any fields.
              
                  // Fail the request if no spinner was passed
                  if (!req.body.spinner) {
              Severity: Minor
              Found in app/routes/signup/botproof.js - About 55 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

              Function resetPassword has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              exports.resetPassword = (username, newPass, cb) => {
                if (!userAttr.usernameRegex.test(username)) {
                  return cb(new Error('Illegal username specified'));
                }
              
              
              Severity: Minor
              Found in app/ldap.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 field.focus();
              Severity: Major
              Found in resource/scripts/signup.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return setTimeout(next, minimumTime - diff);
                Severity: Major
                Found in app/routes/signup/botproof.js - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language