-
Notifications
You must be signed in to change notification settings - Fork 300
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
More easily detect overridden methods & calls to super #982
Comments
Hey, I agree that this would be nice to have in the core, since it already came up a couple of times. Regarding your current code it's hard for me to say where the problem is, because if I just copy your code and add some dummy code I can't reproduce the problem 🤔 If you want me to look into your concrete example, then maybe you can give me a full example to reproduce the problem? One thing I'm not completely sure about is why in In any case, regarding the API, would you picture something like |
Hmm I won't have access to a laptop to provide you with the compete example until January, as I'm on holiday right now. I did have the same use case in this example. Can't mentally reproduce the exact edge cases for the duplicated checks, but know I went through quite a few iterations before I landed on this implementation, with feedback from all the projects where I applied this. Indeed a boolean method to indicate when a method overrides (any) super class or interface method would be helpful! |
Could I take on this issue? |
@java-coding-prodigy sure, if you're open I'd be happy 🙂 |
Yes, I am ready to contribute. |
Sure, you can always ask any questions and I'll try to support you as well as possible 🙂 |
So what exactly am I supposed to implement here? |
I think that would be a good start, yes 🙂 If we later on see that there is something more we need, we can still extend it. But from what I saw so far |
That would be very helpful indeed! :) |
On a recent project we're heavily using the visitor pattern, and would like to ensure that people who override visitor methods call the super implementation. Seemed to me like a reasonable thing to check with ArchUnit, for fast feedback. Yet when implementing this I found there's some challenges with the current APIs, which might benefit from explicitly named constructs in the DSL.
Here's a reproduction sample of the domain:
I'm able for the simplest case to test this using the below constructs:
Yet the
OverridesSuperClassMethod
&CallSuperClassMethod
conditions are awkward and fragile to implement.Worse still, the conditions as they are right now break down when we add subclasses into the mix:
Not immediately clear to me why this would add a violation for
GoodJavaVisitor
or two violations forBadJavaVisitor
.Would it be possible to implement detection of overridden methods & calls to super methods properly once in ArchUnit, and make that available through the API? That way more people can add similar checks more easily.
The text was updated successfully, but these errors were encountered: