Skip to content

Commit 5db8af0

Browse files
#95 Performing ScmLogInfo lookup in parallel
1 parent 20018e5 commit 5db8af0

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

cost-benefit-calculator/src/main/java/org/hjug/cbc/CostBenefitCalculator.java

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -236,25 +236,23 @@ private List<GodClass> getGodClasses() {
236236
}
237237

238238
<T extends Disharmony> List<ScmLogInfo> getRankedChangeProneness(List<T> disharmonies) {
239-
List<ScmLogInfo> scmLogInfos = new ArrayList<>();
240239
log.info("Calculating Change Proneness");
241-
for (Disharmony disharmony : disharmonies) {
242-
String path = disharmony.getFileName();
243-
ScmLogInfo scmLogInfo = null;
244-
try {
245-
scmLogInfo = gitLogReader.fileLog(path);
246-
log.info("Successfully fetched scmLogInfo for {}", scmLogInfo.getPath());
247-
} catch (GitAPIException | IOException e) {
248-
log.error("Error reading Git repository contents.", e);
249-
} catch (NullPointerException e) {
250-
log.error("Encountered nested class in a class containing a violation. Class: {}", path);
251-
}
252240

253-
if (null != scmLogInfo) {
254-
log.info("adding {}", scmLogInfo.getPath());
255-
scmLogInfos.add(scmLogInfo);
256-
}
257-
}
241+
List<ScmLogInfo> scmLogInfos = disharmonies.parallelStream()
242+
.map(disharmony -> {
243+
String path = disharmony.getFileName();
244+
ScmLogInfo scmLogInfo = null;
245+
try {
246+
scmLogInfo = gitLogReader.fileLog(path);
247+
log.info("Successfully fetched scmLogInfo for {}", scmLogInfo.getPath());
248+
} catch (GitAPIException | IOException e) {
249+
log.error("Error reading Git repository contents.", e);
250+
} catch (NullPointerException e) {
251+
log.error("Encountered nested class in a class containing a violation. Class: {}", path);
252+
}
253+
return scmLogInfo;
254+
})
255+
.collect(Collectors.toList());
258256

259257
changePronenessRanker.rankChangeProneness(scmLogInfos);
260258
return scmLogInfos;

0 commit comments

Comments
 (0)