Back to all reviewers

Control structure formatting

facebook/yoga
Based on 2 comments
Java

Always use braces for control structures (if, for, while, etc.) even for single statements, and maintain consistent spacing around parentheses and braces. This improves code readability and prevents potential bugs when code is modified later.

Code Style Java

Reviewer Prompt

Always use braces for control structures (if, for, while, etc.) even for single statements, and maintain consistent spacing around parentheses and braces. This improves code readability and prevents potential bugs when code is modified later.

Use proper spacing with a space after the keyword and before the opening parenthesis, and place the opening brace on the same line with a space before it:

// Good
if (attrs != null) {
    layoutParams = new LayoutParams(context, attrs);
}

// Avoid
if(attrs != null){
    layoutParams = new LayoutParams(context, attrs);
}

// Avoid (missing braces)
if (attrs != null)
    layoutParams = new LayoutParams(context, attrs);

This standard ensures consistent formatting across the codebase and makes code easier to read and maintain.

2
Comments Analyzed
Java
Primary Language
Code Style
Category

Source Discussions