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.
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:
Enter the URL of a public GitHub repository