...
All rules, listed in this document, supplement or override the rules of the Google Java Style Guide.
Table of Contents |
---|
...
Java code has a column limit of 140 characters.
This rule overrides section 4.6.3 of Google Java Style Guide.
Alignment can aid readability, but it creates problems for future maintenance. So horizontal alignment is disallowed.
All natural language sentences must follow generally accepted punctuation rules. It also means that every sentence must end with dot (.
), exclamation point (!
) or question mark (?
) depending on sentence semantics. This requirement applies to:
Exclusions:
...
Ignite 3 uses JetBrains nullability annotations. For the sake of code clarity, it is prohibited to use use @NotNull
annotation, even if it compromises the completeness of the static analysis. However, it is required to use @Nullable
in the following places:
...
There are multiple ways to annotate a Java array, which lead to different interpretation interpretations by the static analysis tool:
...
All these options will be set automatically , when importing inspections settings from the repository.
...
Based on this statement there are limited uses cases where var
keyword is allowed. The var
keyword is allowed only in cases where a right part of an assignment expression contains an explicit type of variable, that is for assignments of literals and the result of constructor invocation.
Allowed only for assignments of literals and , result of constructor invocation and explicit casts:
Code Block | ||
---|---|---|
| ||
var i = 42;
var l = 42L;
var s = "Hello";
var list = new ArrayList<Integer>();
var t = (long) l; |
Disallowed for all other cases:
Code Block | ||
---|---|---|
| ||
var i = Integer.parseInt("42"); var s = "Hello".substring(0, 3); var list = Arrays.asList(1, 2, 3); var map = getMapping(); // some method invocation var val = map.get(42); |
async
suffixAsync method is a method that returns Future
, CompletableFuture
, or CompletionStage
.
In some cases, both sync and async variants exist, and async
suffix is used to distinguish between them:
Code Block | ||
---|---|---|
| ||
void upsert(@Nullable Transaction tx, R rec);
CompletableFuture<Void> upsertAsync(@Nullable Transaction tx, R rec); |
In other cases, only async variant may be present, but it should have the async
suffix anyway.
CompletableFuture
- not CompletionStage
Historically Apache Ignite developers try to avoid redundant Java object instantiations due to the additional GC pressure. Of course, escape analysis exists but we can't trust this feature and should keep objects instantiation under control where it is possible and justified.
So it is recommended to avoid usage of Stream API at least on the hot code path.
Using of 3rd party libraries in production code is prohibited. But there are some exceptions to this rule: