Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discourage the Use of if Conditions Without Curly Braces #3

Open
lil0uuu opened this issue Dec 15, 2023 · 0 comments
Open

Discourage the Use of if Conditions Without Curly Braces #3

lil0uuu opened this issue Dec 15, 2023 · 0 comments

Comments

@lil0uuu
Copy link

lil0uuu commented Dec 15, 2023

Problem:
In the codebase, it has been observed that some developers are using if conditions without enclosing them in curly braces. This practice, while technically valid, can lead to readability issues and may introduce subtle bugs in the future, especially when additional statements are added.

Suggestion:
I propose that we always use curly braces with if conditions, even if there is only a single statement. This practice enhances code clarity, reduces the likelihood of introducing bugs, and makes it easier for others to understand and maintain the code.

Example:

// Not recommended
if (condition)
    statement;

// Recommended
if (condition) {
    statement;
}

Benefits:
Consistency: Encouraging a uniform coding style across the project.
Readability: Making the code more readable by clearly indicating the scope of the if condition.
Error Prevention: Reducing the chance of introducing bugs when modifying code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant