|
| 1 | +# Working in this repository |
| 2 | + |
| 3 | +Building and testing: the README's "Building and testing locally" section. Gradle runs on the Temurin 21 that |
| 4 | +`mise install` provides, `./gradlew test` is what CI runs, and `./gradlew formatDiff` formats the files you changed. |
| 5 | + |
| 6 | +## Conventions for new code |
| 7 | + |
| 8 | +- **Collections.** Plain `java.util` types. `List.of`, `List.copyOf`, `Map.of` and `Stream.toList()` give |
| 9 | + unmodifiable collections, so new code does not need Guava's `ImmutableList` or `ImmutableMap`; use them only |
| 10 | + where an existing API already hands one over. |
| 11 | +- **Nullability.** One annotation, `javax.annotation.Nullable` (jsr305), the one the code uses; do not add another |
| 12 | + `Nullable`. |
| 13 | +- **Local variables.** `var` wherever the initializer gives the type unchanged, in `for` loops too. Not where it |
| 14 | + would box a primitive (`for (var n : List<Integer>)`), and not without an initializer that has a type of its own |
| 15 | + (a lambda, `null`). |
| 16 | +- **Immutability annotations.** Do not add Error Prone's `@Immutable` or `@SuppressWarnings("Immutable")`. |
| 17 | +- **License header.** A new file starts with the Apache 2.0 header alone, without a copyright line: |
| 18 | + |
| 19 | + ```java |
| 20 | + /* |
| 21 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 22 | + * you may not use this file except in compliance with the License. |
| 23 | + * You may obtain a copy of the License at |
| 24 | + * |
| 25 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 26 | + * |
| 27 | + * Unless required by applicable law or agreed to in writing, software |
| 28 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 29 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 30 | + * See the License for the specific language governing permissions and |
| 31 | + * limitations under the License. |
| 32 | + */ |
| 33 | + ``` |
| 34 | + |
| 35 | + Files inherited from google-java-format and palantir-java-format keep their original headers. |
0 commit comments