Skip to content

Commit 760d781

Browse files
authored
Add static import rule for agents (#11290)
Add static import rule for agents Co-authored-by: andrea.marziali <andrea.marziali@datadoghq.com>
1 parent 4ee2247 commit 760d781

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ docs/ Developer documentation (see below)
5656
## Code conventions
5757

5858
- **Formatting**: google-java-format enforced via Spotless. Run `./gradlew spotlessApply` before committing.
59+
- **Static imports**: Prefer static imports over class-qualified calls for call-style helpers — JUnit `Assertions`, Mockito (`mock`, `when`, `verify`, `anyString`, `RETURNS_DEFAULTS`, ...), Hamcrest/AssertJ matchers, internal test DSLs, and similar. Same goes for production code: `Collections.emptyList()` is fine, but if you find yourself repeatedly writing `Foo.bar(...)` where `Foo` adds no information at the call site, static-import `bar`. Wildcard `import static x.*` is disallowed (enforced by IDE config in CONTRIBUTING.md).
5960
- **Instrumentation layout**: `dd-java-agent/instrumentation/{framework}/{framework}-{minVersion}/`
6061
- **Instrumentation pattern**: Type matching → Method matching → Advice class (bytecode advice, not AOP)
6162
- **Test frameworks**: Always use JUnit 5. **Do not write new Groovy / Spock tests** and migrate the existing one to JUnit 5 if it is written in Groovy.

0 commit comments

Comments
 (0)