aisutils icon indicating copy to clipboard operation
aisutils copied to clipboard

Add comprehensive Copilot instructions for code style and Java 21 usage

Open Copilot opened this issue 3 months ago • 0 comments

Establishes coding conventions and test patterns for GitHub Copilot to follow when generating code for this Java 21 project.

Changes

Java 21 Features

  • Pattern matching for instanceof and switch expressions
  • Records for data carriers
  • Text blocks for multi-line strings
  • Switch expressions over statements
  • Sealed classes for closed hierarchies
  • Virtual threads and sequenced collections

Code Style

  • Method Design: Single return statements, short methods with clear single responsibility
  • Immutability: Prefer immutable objects and collections (ImmutableSet, ImmutableMap)
  • Keyword Usage: Use final sparsely, only where meaningful
  • Clean Code: SOLID principles, composition over inheritance, clarity over cleverness

Test Patterns

  • Structure: Arrange-Act-Assert with line comment sections
  • Naming: Use sut for system under test
  • Coverage: Test happy paths, edge cases, boundary conditions, and error handling

Example test structure:

@Test
void testMethodName() {
    // Arrange
    SomeClass sut = new SomeClass();
    
    // Act
    ResultType result = sut.methodUnderTest();
    
    // Assert
    assertEquals(expectedValue, result);
}

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>✨ Set up Copilot instructions</issue_title> <issue_description>use Java 21 features, whereever it makes sense.

Help me write clean, efficient, and maintainable code. Use the latest best practices and design patterns.

I prefer single-return methods. I prefer immutable objects. I prefer short methods that do one thing well. Use keyword final sparsely.

For unit tests use the arrange-act-assert pattern, use JUnit 5 and Mockito for mocking, use the name 'sut' for the system under test and ensure good test coverage. Insert line comments with Arrange, Act and Assert sections in the tests. </issue_description>

Comments on the Issue (you are @copilot in this section)

  • Fixes tbsalling/aisutils#20

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Nov 16 '25 09:11 Copilot