openmrs/openmrs-contrib-id

View on GitHub
app/ldap.js

Summary

Maintainability
D
1 day
Test Coverage

File ldap.js has 427 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';
/**
 * The contents of this file are subject to the OpenMRS Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
Severity: Minor
Found in app/ldap.js - About 6 hrs to fix

    Function updateUser has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.updateUser = (user, cb) => {
      // first check the validity
      checkAndConvert(user);
      const userDn = `${userAttr.rdn}=${user.username},${userAttr.baseDn}`;
    
    
    Severity: Major
    Found in app/ldap.js - About 2 hrs to fix

      Function resetPassword has 49 lines of code (exceeds 25 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 1 hr to fix

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

        const searchRaw = (username, attributes, cb) => {
          if (!_.isArray(attributes)) {
            attributes = [attributes];
          }
          const getAll = username === '*';
        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 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 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

              There are no issues that match your filters.

              Category
              Status