Skip to content

Commit db79275

Browse files
Strum355claude
andcommitted
refactor: extract toStringList helper for TomlArray conversion
Deduplicate the TomlArray-to-string extraction loop that appeared in both members and exclude parsing with identical null/blank filtering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4a1724e commit db79275

1 file changed

Lines changed: 16 additions & 17 deletions

File tree

src/main/java/io/github/guacsec/trustifyda/impl/ExhortApi.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,27 +1023,12 @@ private List<Path> discoverUvWorkspaceMembers(Path workspaceDir, Set<String> ign
10231023
return Collections.emptyList();
10241024
}
10251025

1026-
List<String> memberPatterns = new ArrayList<>();
1027-
for (int i = 0; i < membersArray.size(); i++) {
1028-
String pattern = membersArray.getString(i);
1029-
if (pattern != null && !pattern.isBlank()) {
1030-
memberPatterns.add(pattern.trim());
1031-
}
1032-
}
1026+
List<String> memberPatterns = toStringList(membersArray);
10331027
if (memberPatterns.isEmpty()) {
10341028
return Collections.emptyList();
10351029
}
10361030

1037-
Set<String> excludePatterns = new java.util.HashSet<>();
1038-
TomlArray excludeArray = workspaceConfig.getArray("exclude");
1039-
if (excludeArray != null) {
1040-
for (int i = 0; i < excludeArray.size(); i++) {
1041-
String pattern = excludeArray.getString(i);
1042-
if (pattern != null && !pattern.isBlank()) {
1043-
excludePatterns.add(pattern.trim());
1044-
}
1045-
}
1046-
}
1031+
List<String> excludePatterns = toStringList(workspaceConfig.getArray("exclude"));
10471032

10481033
List<PathMatcher> memberMatchers =
10491034
memberPatterns.stream()
@@ -1084,6 +1069,20 @@ private List<Path> discoverUvWorkspaceMembers(Path workspaceDir, Set<String> ign
10841069
}
10851070
}
10861071

1072+
static List<String> toStringList(TomlArray array) {
1073+
if (array == null) {
1074+
return List.of();
1075+
}
1076+
List<String> result = new ArrayList<>();
1077+
for (int i = 0; i < array.size(); i++) {
1078+
String s = array.getString(i);
1079+
if (s != null && !s.isBlank()) {
1080+
result.add(s.trim());
1081+
}
1082+
}
1083+
return result;
1084+
}
1085+
10871086
/**
10881087
* Discovers Maven multi-module workspace manifests by invoking {@code mvn help:evaluate} to list
10891088
* declared modules, then recursively checking each module for nested aggregators.

0 commit comments

Comments
 (0)