dwyl/hapi-login-example-postgres

View on GitHub

Showing 2 of 2 total issues

Function create_person has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function create_person (request, reply) {
  var email = help.escape(request.payload.email);
  var name = help.escape(request.payload.name);
  var password = help.escape(request.payload.password);
  var select = escape('SELECT * FROM people WHERE (email = %L)', email);
Severity: Minor
Found in lib/handlers/register_handler.js - About 1 hr to fix

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

    function login_handler(request, reply, source, error) {
      // show the registration form until its submitted correctly
      if(!request.payload || request.payload && error) {
        var errors, values; // return empty if not set.
        if(error && error.data) { // only attempt to extract errors if they exist
    Severity: Minor
    Found in lib/handlers/login_handler.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

    Severity
    Category
    Status
    Source
    Language