-
Notifications
You must be signed in to change notification settings - Fork 311
Studying lambda parameters for a forEach method call #1379
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
Comments
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am trying to write a rule such as:
so as to enforce that in certain places all methods must call a method from Validator class.
This works fine and also works fine even if the calls are inside for loops. But case of forEach, the calls go to forEach method, not the methods that are called via the lambda passed onto it.
So
find the forEach calls just fine. From these JavaMethodCall objects it is also possible to find the parameters passed on to forEach, but those are Consumers, not the lambdas themselves.
Is it even possible with ArchUnit to study what is passed as the Consumer?
As a bonus, this works differently with javac and Eclipse Compiler. When compiled with javac, the calls are found directly, but with Eclipse Compiler, the forEach calls are found.
Workaround:
Simple workaround is to just replace forEach calls with normal loops, but it is not ideal in all cases.
The text was updated successfully, but these errors were encountered: