Skip to content

Commit 648d385

Browse files
Use stream over manual loop in wrapForAttribution
1 parent 704980f commit 648d385

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

rewrite-core/src/main/java/org/openrewrite/scheduling/RecipeRunCycle.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import java.util.function.UnaryOperator;
5151

5252
import static java.util.Collections.*;
53+
import static java.util.stream.Collectors.toList;
5354
import static org.openrewrite.ExecutionContext.SCANNING_MUTATION_VALIDATION;
5455
import static org.openrewrite.Recipe.PANIC;
5556

@@ -746,11 +747,7 @@ private void recordSourceFileResult(@Nullable String beforePath, @Nullable Strin
746747
}
747748

748749
private static RecipeError wrapForAttribution(List<Recipe> recipeStack, @Nullable String sourcePath, Throwable t) {
749-
List<String> recipePath = new ArrayList<>(recipeStack.size());
750-
for (Recipe r : recipeStack) {
751-
recipePath.add(r.getName());
752-
}
753-
return new RecipeError(recipePath, sourcePath, t);
750+
return new RecipeError(recipeStack.stream().map(Recipe::getName).collect(toList()), sourcePath, t);
754751
}
755752

756753
private static <S extends SourceFile> S addRecipesThatMadeChanges(List<Recipe> recipeStack, S afterFile) {

0 commit comments

Comments
 (0)