openmrs/openmrs-contrib-id

View on GitHub
app/routes/signup/botproof.js

Summary

Maintainability
C
1 day
Test Coverage

Function spamListLookup has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  spamListLookup: function spamListLookup(req, res, next) {
    const rev = reverseIp(req);
    const spams = signupConf.dnsSpamLists;

    // check the address with each list
Severity: Minor
Found in app/routes/signup/botproof.js - About 2 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

Function spamListLookup has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  spamListLookup: function spamListLookup(req, res, next) {
    const rev = reverseIp(req);
    const spams = signupConf.dnsSpamLists;

    // check the address with each list
Severity: Minor
Found in app/routes/signup/botproof.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 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 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

        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

          There are no issues that match your filters.

          Category
          Status