Applying a Recipe to Test Sources only if Production Sources are Modified #2849
JLLeitschuh
started this conversation in
Polls
Replies: 2 comments 8 replies
-
It should be possible for us to create some sort of recipe which overrides |
Beta Was this translation helpful? Give feedback.
5 replies
-
After some changes to OpenRewrite, the following now works to achieve the desired behaviour. type: specs.openrewrite.org/v1beta/recipe
name: com.example.SecurityModifyRecipe
displayName: Apply `SecureTempFileCreation`
description: Applies the `SecureTempFileCreation` to non-test sources first, if changes are made, then apply to all sources.
applicability:
anySource:
- org.openrewrite.java.search.IsLikelyNotTest
- org.openrewrite.java.security.SecureTempFileCreation
recipeList:
- org.openrewrite.java.security.SecureTempFileCreation |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Context
As an OSS Security Researcher auto-generating security fix PRs at scale across OSS, I often run into maintainers upset when those PRs only modify tests. As such, I'm attempting to come up with a feature where OpenRewrite can filter the applicability of recipe's visitors so they are only applied if the changes will be made BOTH in production AND test. But if the recipe would only change test code, it won't generate a diff at all.
IE: If just a test source will be changed, don't modify anything at all. If a production source file is modified, then also apply the recipe to tests sources as well.
Community Question
Do you ever want to apply a recipe only to tests if production would be modified. Is this a use case you believe would be useful to you? Do you have a similar-but-different filtering problem you'd want to solve that is similar to this?
4 votes ·
Beta Was this translation helpful? Give feedback.
All reactions