Skip to content
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

Report dependecies for generic types and local variables #208

Closed
Glurz opened this issue Jul 31, 2019 · 3 comments
Closed

Report dependecies for generic types and local variables #208

Glurz opened this issue Jul 31, 2019 · 3 comments

Comments

@Glurz
Copy link

Glurz commented Jul 31, 2019

It would be great if ArchUnit would report dependencies on:

  • generic types (e.g. in method return types, method parameters and implemented classes / interfaces) - maybe that's related to Expose type parameters of JavaClass #115?
  • local variables. I was surprised to see that types of local variables are not being checked. I'm aware that this might be difficult or even impossible with reflection. As a consequence, I'm wondering wether it is mandatory to also consider byte code to make reliable statements about dependencies.
@codecholeric
Copy link
Collaborator

Yes, the first point can be solved once #115 is implemented. The issue is also pretty much the same as #144.
As for the second part, I'm not exactly sure I understand you correctly. ArchUnit is looking at the byte code, not using reflection. But yes, ArchUnit is not reading the local variable table if that is what you mean. What is your error scenario though? Because if you have a dependency through a local variable, but ArchUnit does not find it, it also means

  • the type of the local variable does not appear in a method signature
  • it's not a field type
  • you call no method on the type nor access one of its fields
  • you don't anonymously instantiate the type

So in my head this would pretty much mean it's an unused local variable, otherwise some form of other dependency would have to appear. And an unused local variable does not seem to be a problem from an architectural point of view, but simply a code smell that can easily be caught by tools like PMD.

Am I misunderstanding you?

@Glurz
Copy link
Author

Glurz commented Aug 5, 2019

You're totally right - I was playing around with ArchUnit and my example was an unused local variable. Sorry for bothering you.

@Glurz Glurz closed this as completed Aug 5, 2019
@codecholeric
Copy link
Collaborator

No problem 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants