Skip to content

Commit 308c0ad

Browse files
committed
Write down the conventions for new code
CLAUDE.md: plain java.util collections instead of Guava's immutable ones, javax.annotation.Nullable as the one nullability annotation, var for locals, no Error Prone @immutable, and the Apache header without a copyright line on a new file.
1 parent a67fa95 commit 308c0ad

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

‎CLAUDE.md‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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

Comments
 (0)