127 allow bean removal#128
Conversation
There was a problem hiding this comment.
Pull request overview
Introduces a new internal OpenRewrite recipe intended to remove simple, annotated factory methods (e.g., Spring @Bean-like methods) and documents/tests this behavior in the allwrite-recipes module.
Changes:
- Added
RemoveAnnotatedMethodrecipe (internal) with configurable annotation, return type, and allowed body method calls. - Added comprehensive cross-language (Kotlin/Java/Groovy) tests for method-removal eligibility rules.
- Extended
RECIPES.mdwith documentation for the new recipe.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| RECIPES.md | Adds documentation for RemoveAnnotatedMethod (needs corrections to match implementation/package). |
| allwrite-recipes/src/test/kotlin/pl/allegro/tech/allwrite/recipes/spring/RemoveAnnotatedMethodTest.kt | Adds JUnit/RewriteTest coverage for removal behavior across Kotlin/Java/Groovy. |
| allwrite-recipes/src/main/kotlin/pl/allegro/tech/allwrite/recipes/spring/RemoveAnnotatedMethod.kt | Introduces the new internal recipe implementation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
RECIPES.md:727
- In the options table,
returnType/annotationNameare marked as Required=Yes, but their descriptions say the recipe is a no-op when they arenull. These two statements contradict each other; the docs should reflect one consistent contract.
| Name | Type | Required | Description |
|--------------------|---------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `returnType` | `String` | Yes | Fully qualified return type of the method to remove. If `null`, the recipe is a no-op. |
| `annotationName` | `String` | Yes | Fully qualified annotation name the method must have. If `null`, the recipe is a no-op. |
| `allowedBodyCalls` | `Set<String>` | No | Simple method calls permitted in the method body. Any call to a method not in this set blocks removal. Defaults to empty set - only methods with no body calls are removed by default. |
| Any call not in this set causes the method to be treated as complex and skipped""", | ||
| required = false, | ||
| ) | ||
| public val allowedBodyCalls: Set<String> = emptySet(), |
There was a problem hiding this comment.
The allowedBodyCalls is a pretty cryptic name, without the examples I wouldn't be able to understand what it does 😛
How about ignoredMethodNames? We could explain it like this:
By default, any method invocation within the bean method prevents the bean from being removed. You may specify a list of method names that should be ignored during this check.
No description provided.