0

Docs: use 4-space indent in Java styleguide

This is a minor change to rewrite code snippets in
styleguide/java/java.md to use a 4-space indent for Java code snippets.
The codebase already uses a 4-space indent for actual Java code, so it
makes sense that our sample code should follow the real style.

We observed this inconsistency when reviewing
https://crrev.com/c/5447835.

Test: N/A
Change-Id: I76e186d0ce0935b9eb59a296e204a1c94f7913a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5479839
Auto-Submit: Nate Fischer <ntfschr@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1291950}
This commit is contained in:
Nate Fischer
2024-04-24 17:07:26 +00:00
committed by Chromium LUCI CQ
parent 4be138cd97
commit fc38dc8198

@ -52,14 +52,14 @@ Avoid adding messages to exceptions that do not aid in debugging. For example:
```java
try {
somethingThatThrowsIOException();
somethingThatThrowsIOException();
} catch (IOException e) {
// Bad - message does not tell you more than the stack trace does:
throw new RuntimeException("Failed to parse a file.", e);
// Good - conveys that this block failed along with the "caused by" exception.
throw new RuntimeException(e);
// Good - adds useful information.
throw new RuntimeException(String.format("Failed to parse %s", fileName), e);
// Bad - message does not tell you more than the stack trace does:
throw new RuntimeException("Failed to parse a file.", e);
// Good - conveys that this block failed along with the "caused by" exception.
throw new RuntimeException(e);
// Good - adds useful information.
throw new RuntimeException(String.format("Failed to parse %s", fileName), e);
}
```
@ -97,8 +97,8 @@ import org.chromium.build.BuildConfig;
...
if (BuildConfig.ENABLE_ASSERTS) {
// Any code here will be stripped in release builds by R8.
...
// Any code here will be stripped in release builds by R8.
...
}
```
@ -307,7 +307,7 @@ or
```java
if (someConditional) {
return false;
return false;
}
```
@ -315,7 +315,7 @@ Do NOT do:
```java
if (someConditional)
return false;
return false;
```
### Import Order