Robolectric's code style - robolectric/robolectric GitHub Wiki

Java code style

Robolectric follows Google's Java code style and uses google-java-format to check Java code style of every commit on CI. It's recommended to uses google-java-format locally to format your commits before sending PR to Robolectric by following Running-google-java-format.

Note: The Java code style is oriented to commit, not entire project to avoid large conflicts for copybara when syncing code. If you found existing Java formatting problem, it is recommended to send multiple PRs to fix related problems one by one.

Kotlin code style

Robolectric has some Kotlin tests, and it uses Spotless to apply ktfmt for Kotlin code. If you add a new Kotlin module, please follow Applying ktfmt for new Kotlin module to integrate Spotless with ktfmt. Before pushing commits with Kotlin code, please run ./gradlew spotlessCheck to check Kotlin formatting, and ./gradlew spotlessApply to apply formatting suggestions. If ./gradlew spotlessApply can't process all formatting problems, please following suggestions generated by ./gradlew spotlessCheck to fix formatting problems manually.

Note: The Kotlin code style is oriented to entire project because Kotlin code suite is not large.