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

consistent methods for classes() and methods() #239

Closed
destan opened this issue Sep 26, 2019 · 2 comments · Fixed by #314
Closed

consistent methods for classes() and methods() #239

destan opened this issue Sep 26, 2019 · 2 comments · Fixed by #314

Comments

@destan
Copy link

destan commented Sep 26, 2019

classes().that().haveSimpleNameStartingWith() is available but methods().that().haveSimpleNameStartingWith() is not.

we need to use methods().that().haveNameMatching()

wouldn't it be nice to have the methods of classes() and methods() as consistent as possible? or is there a specific reason not to?

@codecholeric
Copy link
Collaborator

Ay, sorry for getting back so late! The reason here was, that ArchUnit is aligned closely with the Java Reflection API to be familiar to Java developers. So there is Class.getSimpleName(), but there is no Method.getSimpleName(). Inconsistencies are mainly taken over from the Java Reflection API, but I think it's worth it in general.
From an ArchUnit point of view, it should maybe be JavaClass.getFullName() for the FQN, JavaClass.getName() for the simple name, and the same for methods, but due to the decision to be consistent to the Reflection API, that's not how it is at the moment.
To be consistent with the current API, we could extend members()...haveName{startingWith,containing,endingWith}(..) similar to classes() with the simple name.

@codecholeric
Copy link
Collaborator

If anybody wants a good starter task 😉, it would be nice to extend the fluent API (i.e. MembersThat and MembersShould) with methods

  • members().that().haveNameStartingWith(..)
  • members().that().haveNameContaining(..)
  • members().that().haveNameEndingWith(..)
  • members().should().haveNameStartingWith(..)
  • members().should().haveNameContaining(..)
  • members().should().haveNameEndingWith(..)

@codecholeric codecholeric added this to In progress in ArchUnit Apr 9, 2020
ArchUnit automation moved this from In progress to Done May 24, 2020
codecholeric added a commit that referenced this issue May 24, 2020
#314

… containing and ending functionality and their negations.
codecholeric pushed a commit that referenced this issue Feb 21, 2021
… ending functionality. (#239)

Signed-off-by: Kamer Elciyar <kamer@kamerelciyar.com>
codecholeric added a commit that referenced this issue Feb 21, 2021
#314

… containing and ending functionality and their negations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
ArchUnit
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants