mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-15 08:17:18 +00:00
[feature][@CheckReturnValue] Add @lombok.CheckReturnValue to generated methods where the return value should not be ignored.
Adds the annotation to @With, @WithBy, @Builder.build(), and @SuperBuilder.build() methods. Controlled via lombok.addCheckReturnValueAnnotation config key (default: true). Static analysis tools (Error Prone, IntelliJ, SpotBugs) recognize @CheckReturnValue by simple name and will warn when the return value is discarded.
This commit is contained in:
1 parent
277c7bf34a
commit
cdfb0f551e
21 files changed
+277
-8
No files matched your search
@@ -0,0 +1,5 @@
|
||||
@lombok.Builder
|
||||
class CheckReturnValueBuilder {
|
||||
private final int x;
|
||||
private final String name;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
//CONF: lombok.addCheckReturnValueAnnotation = false
|
||||
import lombok.With;
|
||||
class CheckReturnValueOff {
|
||||
@With final int x;
|
||||
|
||||
CheckReturnValueOff(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import lombok.With;
|
||||
class CheckReturnValueWith {
|
||||
@With final int x;
|
||||
@With final String name;
|
||||
|
||||
CheckReturnValueWith(int x, String name) {
|
||||
this.x = x;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user