Skip to content

Quite a few uses of strange if/else if/else's #40

Description

@finnhodgkin

In a few places in your codebase you're nesting if statements within the else block of an if statement, why not just use else if?

if (error) {
        console.log('error checking username', err);
      } else {
        if (result == true) {
          res.writeHead(200, { 'Content-Type': 'text/html' });
          res.end(JSON.stringify('username already exists'));
        } else {

vs

if (error) {
  // HANDLE THE ERRORS
} else if (result == true) {
  res.writeHead(200, { 'Content-Type': 'text/html' });
  res.end(JSON.stringify('username already exists'));
} else {
 THE REST
}

or even

if (error) {
  return // HANDLE THE ERRORS
} else if (result == true) {
  res.writeHead(200, { 'Content-Type': 'text/html' });
  return res.end(JSON.stringify('username already exists'));
}
// THE REST OF YOUR CODE NOT IN A BLOCK.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions