Skip to content

Commit d5a0544

Browse files
authored
Fix porcelain for consistency check (#13209)
* Add progess output for consisteny check Fixes #12487 * better handling of not present * checkstyle * fix test * fix newline * check for porcelain * fix formatting * fix formatting
1 parent 298ed89 commit d5a0544

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

jabkit/src/main/java/org/jabref/cli/CheckConsistency.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ public void run() {
6666

6767
BibliographyConsistencyCheck consistencyCheck = new BibliographyConsistencyCheck();
6868
BibliographyConsistencyCheck.Result result = consistencyCheck.check(entries, (count, total) -> {
69-
System.out.println(Localization.lang("Checking consistency for entry type %0 of %1", count + 1, total));
69+
if (!sharedOptions.porcelain) {
70+
System.out.println(Localization.lang("Checking consistency for entry type %0 of %1", count + 1, total));
71+
}
7072
});
7173

7274
Writer writer = new OutputStreamWriter(System.out);

jabkit/src/test/java/org/jabref/cli/ArgumentProcessorTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ void checkConsistency() throws URISyntaxException {
146146
commandLine.execute(args.toArray(String[]::new));
147147

148148
String output = outContent.toString();
149+
assertTrue(output.contains("Checking consistency for entry type 1 of 1\n"));
149150
assertTrue(output.contains("Consistency check completed"));
150151

151152
System.setOut(System.out);
@@ -165,7 +166,7 @@ void checkConsistencyPorcelain() throws URISyntaxException {
165166
commandLine.execute(args.toArray(String[]::new));
166167

167168
String output = outContent.toString();
168-
assertEquals("Checking consistency for entry type 1 of 1\n", output);
169+
assertEquals("", output);
169170

170171
System.setOut(System.out);
171172
}

jablib/src/main/java/org/jabref/logic/quality/consistency/BibliographyConsistencyCheck.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ private static void collectEntriesIntoMaps(List<BibEntry> entries, Map<EntryType
8383
for (BibEntry entry : entries) {
8484
EntryType entryType = entry.getType();
8585

86-
Set<Field> fieldsInAnyEntry = entryTypeToFieldsInAnyEntryMap.computeIfAbsent(entryType, k -> new HashSet<>());
86+
Set<Field> fieldsInAnyEntry = entryTypeToFieldsInAnyEntryMap.computeIfAbsent(entryType, _ -> new HashSet<>());
8787
fieldsInAnyEntry.addAll(entry.getFields());
8888

89-
Set<Field> fieldsInAllEntries = entryTypeToFieldsInAllEntriesMap.computeIfAbsent(entryType, k -> new HashSet<>(entry.getFields()));
89+
Set<Field> fieldsInAllEntries = entryTypeToFieldsInAllEntriesMap.computeIfAbsent(entryType, _ -> new HashSet<>(entry.getFields()));
9090
fieldsInAllEntries.retainAll(entry.getFields());
9191

92-
Set<BibEntry> entriesOfType = entryTypeToEntriesMap.computeIfAbsent(entryType, k -> new HashSet<>());
92+
Set<BibEntry> entriesOfType = entryTypeToEntriesMap.computeIfAbsent(entryType, _ -> new HashSet<>());
9393
entriesOfType.add(entry);
9494
}
9595
}

0 commit comments

Comments
 (0)