rewrite
rewrite copied to clipboard
`@PackageRecipeTags` annotation on `package-info.java`
Adds a package level annotation for adding tags to recipes at the package-level scope.
Signed-off-by: Jonathan Leitschuh [email protected]
What's changed?
Recipe#getDescriptor now looks for Recipe tags on package-info.java, as well as parent package-info.java.
What's your motivation?
When writing recipes that all fall into a similar set of tags, for example security recipes, you likely want to
tag recipes at the package level, so you don't need to add the same exact tag to every single Recipe.
Anything in particular you'd like reviewers to focus on?
Is the PackageRecipeTags annotation name fine?
Anyone you would like to review specifically?
Anyone!
Have you considered any alternatives or workarounds?
Could write an OpenRewrite-OpenRewrite recipe that modifies every recipe in a package to add a tag.
Any additional context
Checklist
- [x] I've added unit tests to cover both positive and negative cases
- [x] I've read and applied the recipe conventions and best practices
- [x] I've used the IntelliJ IDEA auto-formatter on affected files
I like the concept, but rather than adding a package level annotation, I think this concept would better fit in our category resource concept. Categories are tied to packages so putting tags on the category should apply to all recipes in that category. There is a category yml format.
Can you elaborate upon what the difference between categories and tags, at a high level, are supposed to be.
I also had a similar realization, once I realized that categories existed. The annoying downside is that those category added tags won't show up when you call getDescriptor().getTags() but I don't think that's a big deal.