Back to all reviewers

Use consistent control structures

nestjs/nest
Based on 4 comments
TypeScript

Always use curly braces for control structures (if, for, while, etc.), even for single-line statements. This improves code readability and maintainability by making the code structure explicit and consistent.

Code Style TypeScript

Reviewer Prompt

Always use curly braces for control structures (if, for, while, etc.), even for single-line statements. This improves code readability and maintainability by making the code structure explicit and consistent.

Example:

// Incorrect
if (areThereNoFileIn && this.fileIsRequired) return;

// Correct
if (areThereNoFileIn && this.fileIsRequired) {
  return;
}

// Incorrect
if (this.flushLogsOnOverride) this.flushLogs();

// Correct
if (this.flushLogsOnOverride) {
  this.flushLogs();
}

This style:

  • Prevents errors when adding more statements later
  • Makes code structure immediately clear
  • Maintains consistency across the codebase
  • Makes code reviews more efficient by eliminating style discussions
  • Reduces cognitive load when reading code
4
Comments Analyzed
TypeScript
Primary Language
Code Style
Category

Source Discussions