Skip to content

Commit 6588b92

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 8602496 commit 6588b92

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
@@ -966,27 +966,12 @@ private List<Path> discoverUvWorkspaceMembers(Path workspaceDir, Set<String> ign
966966
return Collections.emptyList();
967967
}
968968

969-
List<String> memberPatterns = new ArrayList<>();
970-
for (int i = 0; i < membersArray.size(); i++) {
971-
String pattern = membersArray.getString(i);
972-
if (pattern != null && !pattern.isBlank()) {
973-
memberPatterns.add(pattern.trim());
974-
}
975-
}
969+
List<String> memberPatterns = toStringList(membersArray);
976970
if (memberPatterns.isEmpty()) {
977971
return Collections.emptyList();
978972
}
979973

980-
Set<String> excludePatterns = new java.util.HashSet<>();
981-
TomlArray excludeArray = workspaceConfig.getArray("exclude");
982-
if (excludeArray != null) {
983-
for (int i = 0; i < excludeArray.size(); i++) {
984-
String pattern = excludeArray.getString(i);
985-
if (pattern != null && !pattern.isBlank()) {
986-
excludePatterns.add(pattern.trim());
987-
}
988-
}
989-
}
974+
List<String> excludePatterns = toStringList(workspaceConfig.getArray("exclude"));
990975

991976
List<PathMatcher> memberMatchers =
992977
memberPatterns.stream()
@@ -1027,6 +1012,20 @@ private List<Path> discoverUvWorkspaceMembers(Path workspaceDir, Set<String> ign
10271012
}
10281013
}
10291014

1015+
static List<String> toStringList(TomlArray array) {
1016+
if (array == null) {
1017+
return List.of();
1018+
}
1019+
List<String> result = new ArrayList<>();
1020+
for (int i = 0; i < array.size(); i++) {
1021+
String s = array.getString(i);
1022+
if (s != null && !s.isBlank()) {
1023+
result.add(s.trim());
1024+
}
1025+
}
1026+
return result;
1027+
}
1028+
10301029
/**
10311030
* Checks whether a package.json has "private": true, meaning it should not be analyzed as a
10321031
* publishable package.

0 commit comments

Comments
 (0)