From d0ead4e210fea3bc54ee38af614714b80c8e651b Mon Sep 17 00:00:00 2001 From: andrecs <12188364+andrecsilva@users.noreply.github.com> Date: Mon, 14 Oct 2024 08:58:55 -0300 Subject: [PATCH] Small refactoring --- .../codemodder/remediation/SearcherStrategyRemediator.java | 7 +++---- .../java/io/codemodder/remediation/SuccessOrReason.java | 5 +++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/framework/codemodder-base/src/main/java/io/codemodder/remediation/SearcherStrategyRemediator.java b/framework/codemodder-base/src/main/java/io/codemodder/remediation/SearcherStrategyRemediator.java index 557557c3e..dcac0f6bf 100644 --- a/framework/codemodder-base/src/main/java/io/codemodder/remediation/SearcherStrategyRemediator.java +++ b/framework/codemodder-base/src/main/java/io/codemodder/remediation/SearcherStrategyRemediator.java @@ -140,8 +140,7 @@ public CodemodFileScanningResult remediateAll( List allChanges = new ArrayList<>(); List allUnfixed = new ArrayList<>(); - for (var searcher : searcherRemediatorMap.keySet()) { - var strategy = searcherRemediatorMap.get(searcher); + for (var searcherAndStrategy : searcherRemediatorMap.entrySet()) { var pairResult = remediateWithStrategy( cu, @@ -152,8 +151,8 @@ public CodemodFileScanningResult remediateAll( findingStartLineExtractor, findingEndLineExtractor, findingColumnExtractor, - searcher, - strategy); + searcherAndStrategy.getKey(), + searcherAndStrategy.getValue()); allChanges.addAll(pairResult.getValue0()); allUnfixed.addAll(pairResult.getValue1()); } diff --git a/framework/codemodder-base/src/main/java/io/codemodder/remediation/SuccessOrReason.java b/framework/codemodder-base/src/main/java/io/codemodder/remediation/SuccessOrReason.java index d806d9ebc..67e2f1514 100644 --- a/framework/codemodder-base/src/main/java/io/codemodder/remediation/SuccessOrReason.java +++ b/framework/codemodder-base/src/main/java/io/codemodder/remediation/SuccessOrReason.java @@ -3,6 +3,7 @@ import io.codemodder.DependencyGAV; import io.codemodder.Either; import java.util.List; +import java.util.NoSuchElementException; import java.util.Objects; /** @@ -27,14 +28,14 @@ public boolean isSuccess() { public List getDependencies() { if (!isSuccess()) { - throw new RuntimeException("Trying to get dependencies from a failure result"); + throw new NoSuchElementException("Trying to get dependencies from a failure result"); } return either.getLeft(); } public String getReason() { if (isSuccess()) { - throw new RuntimeException("Trying to get a reason from a successful result"); + throw new NoSuchElementException("Trying to get a reason from a successful result"); } return either.getRight(); }