add a @Generated and @Nullable annotations
See original GitHub issuestatic analysis tools will now (often) recognize these by name alone, so it would be ideal if Immutables provided them. Example of problems
/Users/calebcushing/IdeaProjects/ppm/scaf/build/generated/sources/annotationProcessor/java/main/com/xenoterracide/scaf/ImmutableSkeletonConfiguration.java:135: error: [UnusedVariable] The parameter 'synthetic' is never read.
private boolean equalTo(int synthetic, ImmutableSkeletonConfiguration another) {
^
(see https://errorprone.info/bugpattern/UnusedVariable)
Did you mean '&& equalTo((ImmutableSkeletonConfiguration) another);'?
/Users/calebcushing/IdeaProjects/ppm/scaf/build/generated/sources/annotationProcessor/java/main/com/xenoterracide/scaf/ImmutableSkeletonConfiguration.java:148: error: [Var] Non-constant variable missing @Var annotation
int h = 5381;
^
(see https://errorprone.info/bugpattern/Var)
Did you mean '@Var int h = 5381;'?
/Users/calebcushing/IdeaProjects/ppm/scaf/build/generated/sources/annotationProcessor/java/main/com/xenoterracide/scaf/ImmutableSkeletonConfiguration.java:179: error: [NullAway] @NonNull field ImmutableSkeletonConfiguration$Json.templateSourceType not initialized
Application.SourceType templateSourceType;
^
(see http://t.uber.com/nullaway )
/Users/calebcushing/IdeaProjects/ppm/scaf/build/generated/sources/annotationProcessor/java/main/com/xenoterracide/scaf/ImmutableSkeletonConfiguration.java:180: error: [NullAway] @NonNull field ImmutableSkeletonConfiguration$Json.source not initialized
String source;
^
(see http://t.uber.com/nullaway )
/Users/calebcushing/IdeaProjects/ppm/scaf/build/generated/sources/annotationProcessor/java/main/com/xenoterracide/scaf/ImmutableSkeletonConfiguration.java:181: error: [NullAway] @NonNull field ImmutableSkeletonConfiguration$Json.destination not initialized
String destination;
^
(see http://t.uber.com/nullaway )
/Users/calebcushing/IdeaProjects/ppm/scaf/build/generated/sources/annotationProcessor/java/main/com/xenoterracide/scaf/ImmutableSkeletonConfiguration.java:182: error: [NullAway] @NonNull field ImmutableSkeletonConfiguration$Json.after not initialized
Pattern after;
^
(see http://t.uber.com/nullaway )
/Users/calebcushing/IdeaProjects/ppm/scaf/build/generated/sources/annotationProcessor/java/main/com/xenoterracide/scaf/ImmutableSkeletonConfiguration.java:285: error: [NullAway] initializer method does not guarantee @NonNull fields templateSourceType (line 280), source (line 281), destination (line 282), after (line 283) are initialized along all control-flow paths (remember to check for exceptions or early returns).
private Builder() {
^
(see http://t.uber.com/nullaway )
and source
@Value.Immutable
@JsonSerialize(as = ImmutableSkeletonConfiguration.class)
@JsonDeserialize(as = ImmutableSkeletonConfiguration.class)
interface SkeletonConfiguration {
SourceType getTemplateSourceType();
String getSource();
String getDestination();
Pattern getAfter();
}
I’ve tried this and subsets of gradle.build.kts (btw, you might want to update the get started documentation with how do do this)
annotationProcessor("org.immutables:value:2.+")
errorprone("org.immutables:value:2.+")
errorprone("org.immutables:value-annotations:2.+")
errorprone("com.google.errorprone:error_prone_core:2.4.+")
errorprone("com.uber.nullaway:nullaway:0.8.+")
compileOnly("org.immutables:value-annotations:2.+")
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
@Nullable and @NotNull | IntelliJ IDEA Documentation
@Nullable and @NotNull annotations let you check nullability of a variable, parameter, or return value. They help you control contracts ...
Read more >Update your codebase to use nullable reference types
You turn on nullable reference types as you annotate APIs. When you've finished, you enable nullable reference types for the entire project.
Read more >Add option to generate C# nullable annotations #6632 - GitHub
C# 8.0 adds support for nullability annotations. It would be helpful if the the generated protobuf objects added these annotations. This would ...
Read more >The annotation for nullable reference types should only be ...
csproj file. This element configures how the compiler interprets the nullability of types and what warnings are generated.
Read more >Improve code inspection with annotations - Android Developers
Add @Nullable and @NonNull annotations to check the nullness of a given variable, parameter, or return value. The @Nullable annotation indicates a variable, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m one of those folks, but have since decided to simply skip Error Prone analysis of generated code. Our Maven build contains the following Error Prone config:
(The first flag disables analysis of all
@Generated
code, even if it’s checked in (🙈). The second flag disables analysis of all code generated at build time, even if not marked@Generated
. Additionally, it prevents Error Prone from looking at such code at all, providing a small performance boost.)For an example see our open-source parent
pom.xml
. Since we enable nearly all Error Prone checks, skipping analysis of generated code seems to be the only pragmatic approach.appears that the
@NotNull
is probably an issue with the fact that theannotation
module isn’t documented, and doesn’t seem to work as advertised.