0

How would I write a check which checks if the class is in the right package according to its suffix, eg.: class named DateTimeUtils should be in a package ending in *.util?

mdenci
  • 297
  • 2
  • 6
  • 17
  • Does this answer your question? [How to get current class name including package name in Java?](https://stackoverflow.com/questions/9729197/how-to-get-current-class-name-including-package-name-in-java) – vincrichaud Apr 20 '23 at 11:50
  • 1
    @vincrichaud Checkstyle doesn't have access to reflection – Rob Spoor Apr 20 '23 at 13:29
  • I think you can write a sub class of `AbstractFileSetCheck` for this (see https://checkstyle.sourceforge.io/writingchecks.html). It has access to the file, and therefore the filename and path. – Rob Spoor Apr 20 '23 at 13:30

0 Answers0