-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing override annotation on generated methods #1343
Comments
I think we originally did not add it because it wasn't a legit move in java 1.5 or 1.6 for interfaces, except this isn't even an interface. I really see no reason NOT to gen an |
We generate Without further feedback, this issue can be closed starting on March 31st. |
NB: If it's about 'canEqual', we can't add |
One example can be noted here: Where @Getter
public abstract class AbstractRandomStringGenerator implements ... {
private int defaultLength;
...
} This is with Lombok |
We cannot generate
This should tell error-prone to not generate warnings on lombok generated methods. |
Thank you for the suggestions. I believe that setting is and was already in place when I captured the screenshot. But I must admit I don't follow your note above: The method PS: If I actually delombok the @getter annotation in the above abstract class, I see: public int getDefaultLength() {
return this.defaultLength;
} |
Ah, never mind. I see what you meant. Thanks for the hint! (It is curious though why the setting does not quire suppress the warnings) |
yeah, that setting does not seem to suppress warning generated by error-prone. |
I don't think Error Prone cares about the
and pass the Alternatively, for getters and setters, you can manually tell Lombok to add the @Getter(onMethod = @__({@Override})) @Setter(onMethod = @__({@Override})) String foo; Unfortunately, at this time I don't think there's a Java 9 compatible solution for the @rzwitserloot Do you think it would be possible to add something like [0] https://projectlombok.org/features/configuration |
Hi. I'm hitting this problem consistently
I'm implementing a Rest service and have an hierarchy of objects which are mapped from JSON to POJOs using I also have some interfaces I use to abstract away each different object when implementing the business logic. Something like:
The problem is that When compiling I get these warnings:
I'd really like if lombok was a bit smarter with these annotations and peeked into the hierarchy to see if there is a method with the same signature and if so, add the I'm using IntelliJ. If I delombok the files, I see that the common methods like Thank you. |
Unfortunately we cannot look at the hierarchy, it requires resolution, see https://github.com/rzwitserloot/lombok/wiki/LOMBOK-CONCEPT:-Resolution |
Ah, I see. I did not know that lombok pre-compiled the files. Then perhaps just add something extra that allows the developer to easily inject that 1. Regarding the case of overriding a setter: It's easy to add a I'd suggest something to simplify that case like at the class level In case of a class level annotation, also allow that info to be passed from 2. Regarding I can't think of anything elegant, although I think it does not make sense to add some argument to the annotation just to hint lombok to add the How about renaming that method to Extra: |
|
Would this work? If so, is there any reason not to do it? |
…ationResult and KubernetesRunJobDeploymentResult The remaining missing @OVERRIDES warnings are for the `canEqual` methods generated by Lombok's @EqualsAndHashCode. This is a [known issue](projectlombok/lombok#1343), but before we suppress the remaining warnings, let's remove unnecessary uses of @EqualsAndHashCode. OperationResult is annotated with @DaTa, which is equivalent to the following annotations: @getter, @Setter, @requiredargsconstructor, @tostring, and @EqualsAndHashCode. This commit replaces OperationResult's @DaTa and @NoArgsConstructor with field-level @getterS and @setters and an explicit no-args constructor. As a result, KubernetesRunJobDeploymentResult no longer requires its own @EqualsAndHashCode(callSuper = true). Also replaces its @DaTa with field-level @getter and @Setter. Let's try to avoid using @DaTa in the future for classes without a notion of logical equality that would require @EqualsAndHashCode, and instead just add the constructors and @getterS and @setters we actually need.
We also have trouble with missing @OverRide at canEqual Method and we need to disable the error for missing overrides in eclipse project settings. I think it is safe to generate the @OverRide as long as I only subclass other objects that also have the canEqual method. Maybe add an additional setting wether the @OverRide should alsways be generated at canEqual or not. |
This should be solved by google/error-prone#2125. So now error prone should be able to properly detect Lombok's generated code (assuming |
At work, we used to tag missing override annotations as errors.
When using @EqualsAndHashCode, the compiler complains about the lack of the @OverRide annotation.
The case also appears when having an interface declaring specific accessors.
Would it be possible to add this missing annotation when appropriate ?
The text was updated successfully, but these errors were encountered: