From 66dc6c934f501e715a8d9645d25ce57f1664cd18 Mon Sep 17 00:00:00 2001 From: jason plumb <75337021+breedx-splk@users.noreply.github.com> Date: Mon, 1 Feb 2021 18:04:56 -0800 Subject: [PATCH] Document the static imports (style guidelines) (#2161) * document the static imports that we like * spotless * Update docs/contributing/style-guideline.md Co-authored-by: Trask Stalnaker Co-authored-by: Trask Stalnaker --- docs/contributing/style-guideline.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/contributing/style-guideline.md b/docs/contributing/style-guideline.md index 2b72d8631e..ee04ac1dee 100644 --- a/docs/contributing/style-guideline.md +++ b/docs/contributing/style-guideline.md @@ -52,3 +52,17 @@ To run these checks locally: ``` ./gradlew checkstyleMain checkstyleTest ``` + +### Static imports + +We leverage static imports for many common types of operations. However, not all static methods or +constants are necessarily good candidates for a static import. The following list is a very +rough guideline of what are commonly accepted static imports: + +* Test assertions (JUnit and AssertJ) +* Mocking/stubbing in tests (with Mockito) +* Collections helpers (such as `singletonList()` and `Collectors.toList()`) +* ByteBuddy `ElementMatchers` (for building instrumentation modules) +* Immutable constants (where clearly named) +* Singleton instances (especially where clearly named an hopefully immutable) +* `tracer()` methods that expose tracer singleton instances