Search code examples
javaandroidandroid-studiobraces

In java code search helper to find all places where braces is missing


Lets say I have a bunch of code and all the braces are gone like

Look no braces:
if(condition)
  statement;

Yes java code convention using braces
if(condition)
{
  statement;
}

In particularly for Android Studio would be nice if there was a e.g. Lint check maybe?


Solution

  • You can fix this in the android studio settings:

    Settings → Editor → Code Style → Java → 'if()' statement.

    Then set Force braces to Always. After that, you can run Ctrl+Alt+L to format the current file to the right conventions.

    if you want to format all the files in a directory simply:
    right click on the folder → Reformat code