Skip to content

Add docs/JAVA.md with Java-specific guidance#2974

Merged
afranken merged 2 commits intomainfrom
copilot/extract-java-guidance
Feb 25, 2026
Merged

Add docs/JAVA.md with Java-specific guidance#2974
afranken merged 2 commits intomainfrom
copilot/extract-java-guidance

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

Java code exists in the project (testsupport modules) but had no canonical style reference, unlike Kotlin which has docs/KOTLIN.md.

Changes

  • docs/JAVA.md — New Java guidelines document mirroring the structure of docs/KOTLIN.md:

    • Style rules derived from the enforced Checkstyle config (etc/checkstyle.xml): 2-space indent, 120-char line limit, mandatory braces, import ordering
    • Modern Java idioms: var, List.of(), streams, switch expressions, text blocks
    • Anti-patterns table (same format as KOTLIN.md)
    • Naming conventions aligned with Google Java Style and existing checkstyle rules (abbreviation limits, casing)
    • Test naming: descriptive verb-phrase method names matching existing Java test style
    • Javadoc guidelines consistent with checkstyle tag-order and comment philosophy
  • AGENTS.md — Added reference to docs/JAVA.md in the Code Style section alongside the existing docs/KOTLIN.md reference

Original prompt

Extract java specific guidance similar to kotlin related guidance.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: afranken <763000+afranken@users.noreply.github.com>
Copilot AI changed the title [WIP] Extract Java specific guidance similar to Kotlin guidance Add docs/JAVA.md with Java-specific guidance Feb 25, 2026
@afranken afranken requested a review from Copilot February 25, 2026 20:41
@afranken afranken marked this pull request as ready for review February 25, 2026 20:41
@afranken afranken self-requested a review as a code owner February 25, 2026 20:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a canonical Java style/idioms guide to complement the existing Kotlin guidance, and links it from the main contributor agent context so Java changes (notably in testsupport/) have a consistent reference.

Changes:

  • Added docs/JAVA.md with Java-specific style, naming, test naming, and Javadoc guidance derived from the project’s Checkstyle configuration.
  • Updated AGENTS.md to reference the new Java guidelines alongside docs/KOTLIN.md.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
docs/JAVA.md Introduces Java guidelines (style + idioms + anti-patterns + naming + tests + Javadoc).
AGENTS.md Links the new Java guidelines from the project’s Code Style section.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +41 to +48
| Anti-Pattern | Refactor To |
|---|---|
| `list.size() == 0` | `list.isEmpty()` |
| `Collections.emptyList()` | `List.of()` |
| `Collections.unmodifiableList(new ArrayList<>(...))` | `List.copyOf(...)` |
| `"" + value` | `String.valueOf(value)` or `String.format(...)` |
| Empty catch blocks | At minimum, log the exception |
| Magic numbers/strings | Named constants |
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The anti-patterns table is not valid Markdown because the rows start with || instead of |. This will render incorrectly on GitHub; use a single leading pipe for each row (header, separator, and body).

Copilot uses AI. Check for mistakes.
- **Indentation**: 2 spaces (no tabs)
- **Line length**: 120 characters maximum
- **Braces**: Always use braces for `if`, `for`, `while`, `do` blocks
- **Imports**: Static imports first, then third-party packages; alphabetical within groups; no wildcard imports
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import-order guidance here doesn’t match the enforced Checkstyle config: CustomImportOrder is configured as STATIC###THIRD_PARTY_PACKAGE, which effectively means “static imports first, then all non-static imports” (no separate standard/third-party grouping). Consider rewording this bullet to reflect the actual rule to avoid confusion.

Suggested change
- **Imports**: Static imports first, then third-party packages; alphabetical within groups; no wildcard imports
- **Imports**: Static imports first, then all non-static imports; alphabetical within each group; no wildcard imports

Copilot uses AI. Check for mistakes.
- Use `List.of(...)`, `Map.of(...)` for immutable collections instead of `Collections.unmodifiableList(...)`
- Prefer streams over explicit loops for transformations:
```java
buckets.stream().map(Bucket::name).collect(Collectors.toSet())
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Java snippet is missing a trailing semicolon, so it isn’t a copy/pasteable example. Consider updating it to a syntactically complete statement (and optionally include/import Collectors if you want it to compile standalone).

Suggested change
buckets.stream().map(Bucket::name).collect(Collectors.toSet())
buckets.stream().map(Bucket::name).collect(Collectors.toSet());

Copilot uses AI. Check for mistakes.
Copy link
Member

@afranken afranken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@afranken afranken merged commit 7783a3d into main Feb 25, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants