Skip TemporaryFolder conversion when used in RuleChain. #898
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's changed?
Added a precondition to
TemporaryFolderToTempDirthat skips conversion whenTemporaryFolderis used within aRuleChain. The recipe now detects calls toRuleChain.outerRule()andRuleChain.around()that receive aTemporaryFolderargument, and skips the entire file in those cases.What's your motivation?
When
TemporaryFolderis converted to@TempDir File, the resultingFiletype does not implementTestRule, which breaksRuleChain.around()calls that expect aTestRule. By skipping these cases, the existingHandleExternalResourceRulesrecipe can handle them instead by adding@ExtendWith(ExternalResourceSupport.class).Anything in particular you'd like reviewers to focus on?
The precondition operates at the file level—if any
TemporaryFolderis used in aRuleChain, the entire file is skipped. This is conservative but simple. A more granular approach could convert standaloneTemporaryFolderinstances while skipping only those inRuleChain, but this adds complexity for an edge case (mixed usage in a single file).Anyone you would like to review specifically?
Have you considered any alternatives or workarounds?
RuleChainand only skipping thoseAny additional context
Checklist