From 167558dfe1aaa090e57b9bae672e40a76a78abd0 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 29 Mar 2020 21:57:34 +0200 Subject: [PATCH 1/3] Fix some IntelliJ findings - Fix bug in TagBar (added itself instead of newTags) - Wrong number of LOGGER paramters - Inner class may be static - Fix comment typo - Bulk operation can be used instead of iteration - Arrays.asList with only one element - Optimized count by using numbers earlier - Chained append for StringBuilder - Initialize ArrayList by passing the initial contents in the constructor --- src/main/java/org/jabref/JabRefExecutorService.java | 2 +- src/main/java/org/jabref/JabRefGUI.java | 10 +++++----- src/main/java/org/jabref/gui/BasePanel.java | 2 +- src/main/java/org/jabref/gui/SidePaneManager.java | 2 +- .../java/org/jabref/gui/copyfiles/CopyFilesTask.java | 2 +- .../jabref/gui/duplicationFinder/DuplicateSearch.java | 2 +- .../jabref/gui/exporter/ExportToClipboardAction.java | 2 +- .../gui/fieldeditors/contextmenu/CaseChangeMenu.java | 3 +-- src/main/java/org/jabref/gui/groups/GroupTreeView.java | 2 +- .../org/jabref/gui/groups/UndoableModifySubtree.java | 4 +--- src/main/java/org/jabref/gui/util/BackgroundTask.java | 2 +- .../org/jabref/gui/util/CurrentThreadTaskExecutor.java | 2 +- .../org/jabref/gui/util/IconValidationDecorator.java | 4 ++-- .../java/org/jabref/gui/util/component/TagBar.java | 2 +- .../logic/bibtex/comparator/FieldComparator.java | 6 +++--- src/main/java/org/jabref/logic/bst/VM.java | 4 ++-- src/main/java/org/jabref/logic/cleanup/Cleanups.java | 6 ++---- .../org/jabref/logic/exporter/BibTeXMLExporter.java | 2 +- .../org/jabref/logic/exporter/MetaDataSerializer.java | 2 +- .../org/jabref/logic/exporter/TemplateExporter.java | 7 ++++--- .../org/jabref/logic/importer/ImportFormatReader.java | 4 +--- .../logic/importer/fileformat/MrDLibImporter.java | 2 +- .../java/org/jabref/logic/layout/format/RTFChars.java | 2 +- .../java/org/jabref/logic/msbib/MSBibConverter.java | 8 ++++---- .../jabref/logic/openoffice/OpenOfficeFileSearch.java | 3 ++- 25 files changed, 41 insertions(+), 46 deletions(-) diff --git a/src/main/java/org/jabref/JabRefExecutorService.java b/src/main/java/org/jabref/JabRefExecutorService.java index df127df89f6..10fd1ee19cc 100644 --- a/src/main/java/org/jabref/JabRefExecutorService.java +++ b/src/main/java/org/jabref/JabRefExecutorService.java @@ -143,7 +143,7 @@ public void shutdownEverything() { timer.cancel(); } - private class NamedRunnable implements Runnable { + private static class NamedRunnable implements Runnable { private final String name; diff --git a/src/main/java/org/jabref/JabRefGUI.java b/src/main/java/org/jabref/JabRefGUI.java index 19be513cf87..688227ce923 100644 --- a/src/main/java/org/jabref/JabRefGUI.java +++ b/src/main/java/org/jabref/JabRefGUI.java @@ -215,11 +215,11 @@ private void debugLogWindowState(Stage mainStage) { if (LOGGER.isDebugEnabled()) { StringBuilder debugLogString = new StringBuilder(); debugLogString.append("SCREEN DATA:"); - debugLogString.append("mainStage.WINDOW_MAXIMISED: " + mainStage.isMaximized() + "\n"); - debugLogString.append("mainStage.POS_X: " + mainStage.getX() + "\n"); - debugLogString.append("mainStage.POS_Y: " + mainStage.getY() + "\n"); - debugLogString.append("mainStage.SIZE_X: " + mainStage.getWidth() + "\n"); - debugLogString.append("mainStages.SIZE_Y: " + mainStage.getHeight() + "\n"); + debugLogString.append("mainStage.WINDOW_MAXIMISED: ").append(mainStage.isMaximized()).append("\n"); + debugLogString.append("mainStage.POS_X: ").append(mainStage.getX()).append("\n"); + debugLogString.append("mainStage.POS_Y: ").append(mainStage.getY()).append("\n"); + debugLogString.append("mainStage.SIZE_X: ").append(mainStage.getWidth()).append("\n"); + debugLogString.append("mainStages.SIZE_Y: ").append(mainStage.getHeight()).append("\n"); LOGGER.debug(debugLogString.toString()); } } diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java index 934f93c8133..30ced2ae877 100644 --- a/src/main/java/org/jabref/gui/BasePanel.java +++ b/src/main/java/org/jabref/gui/BasePanel.java @@ -164,7 +164,7 @@ public String getTabTitle() { } } } else if (databaseLocation == DatabaseLocation.SHARED) { - title.append(this.bibDatabaseContext.getDBMSSynchronizer().getDBName() + " [" + Localization.lang("shared") + "]"); + title.append(this.bibDatabaseContext.getDBMSSynchronizer().getDBName()).append(" [").append(Localization.lang("shared")).append("]"); } return title.toString(); diff --git a/src/main/java/org/jabref/gui/SidePaneManager.java b/src/main/java/org/jabref/gui/SidePaneManager.java index 324810dd6ed..55b55d4f795 100644 --- a/src/main/java/org/jabref/gui/SidePaneManager.java +++ b/src/main/java/org/jabref/gui/SidePaneManager.java @@ -176,7 +176,7 @@ private void updateView() { /** * Helper class for sorting visible components based on their preferred position. */ - private class PreferredIndexSort implements Comparator { + private static class PreferredIndexSort implements Comparator { private final Map preferredPositions; diff --git a/src/main/java/org/jabref/gui/copyfiles/CopyFilesTask.java b/src/main/java/org/jabref/gui/copyfiles/CopyFilesTask.java index 2b78f4dd74d..aa3c7982175 100644 --- a/src/main/java/org/jabref/gui/copyfiles/CopyFilesTask.java +++ b/src/main/java/org/jabref/gui/copyfiles/CopyFilesTask.java @@ -50,7 +50,7 @@ public CopyFilesTask(BibDatabaseContext databaseContext, List entries, this.databaseContext = databaseContext; this.entries = entries; this.exportPath = path; - totalFilesCount = entries.stream().flatMap(entry -> entry.getFiles().stream()).count(); + totalFilesCount = entries.stream().mapToLong(entry -> entry.getFiles().size()).sum(); } @Override diff --git a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java index 2c7dc4db6ab..1336e505afc 100644 --- a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java +++ b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java @@ -184,7 +184,7 @@ private void handleDuplicates(DuplicateSearchResult result) { * Uses {@link System#identityHashCode(Object)} for identifying objects for removal, as completely identical * {@link BibEntry BibEntries} are equal to each other. */ - class DuplicateSearchResult { + static class DuplicateSearchResult { private final Map toRemove = new HashMap<>(); private final List toAdd = new ArrayList<>(); diff --git a/src/main/java/org/jabref/gui/exporter/ExportToClipboardAction.java b/src/main/java/org/jabref/gui/exporter/ExportToClipboardAction.java index 94b63150d15..606706a89da 100644 --- a/src/main/java/org/jabref/gui/exporter/ExportToClipboardAction.java +++ b/src/main/java/org/jabref/gui/exporter/ExportToClipboardAction.java @@ -150,7 +150,7 @@ private String readFileToString(Path tmp) throws IOException { } } - private class ExportResult { + private static class ExportResult { final String content; final FileType fileType; diff --git a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/CaseChangeMenu.java b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/CaseChangeMenu.java index 6539516b776..04961cabd06 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/CaseChangeMenu.java +++ b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/CaseChangeMenu.java @@ -23,8 +23,7 @@ public CaseChangeMenu(final StringProperty text) { Objects.requireNonNull(text); // create menu items, one for each case changer - List caseChangers = new ArrayList<>(); - caseChangers.addAll(Formatters.getCaseChangers()); + List caseChangers = new ArrayList<>(Formatters.getCaseChangers()); caseChangers.add(new ProtectTermsFormatter(Globals.protectedTermsLoader)); for (final Formatter caseChanger : caseChangers) { CustomMenuItem menuItem = new CustomMenuItem(new Label(caseChanger.getName())); diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index c26db16fc85..856edb67a19 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -393,7 +393,7 @@ private void setupClearButtonField(CustomTextField customTextField) { } } - private class DragExpansionHandler { + private static class DragExpansionHandler { private static final long DRAG_TIME_BEFORE_EXPANDING_MS = 1000; private TreeItem draggedItem; private long dragStarted; diff --git a/src/main/java/org/jabref/gui/groups/UndoableModifySubtree.java b/src/main/java/org/jabref/gui/groups/UndoableModifySubtree.java index f8d83ed5c5a..1f04933adde 100644 --- a/src/main/java/org/jabref/gui/groups/UndoableModifySubtree.java +++ b/src/main/java/org/jabref/gui/groups/UndoableModifySubtree.java @@ -43,9 +43,7 @@ public void undo() { m_modifiedSubtree.clear(); // get node to edit final GroupTreeNode subtreeRoot = m_groupRoot.getDescendant(m_subtreeRootPath).get(); //TODO: NULL - for (GroupTreeNode child : subtreeRoot.getChildren()) { - m_modifiedSubtree.add(child); - } + m_modifiedSubtree.addAll(subtreeRoot.getChildren()); // keep subtree handle, but restore everything else from backup subtreeRoot.removeAllChildren(); for (GroupTreeNode child : m_subtreeBackup.getChildren()) { diff --git a/src/main/java/org/jabref/gui/util/BackgroundTask.java b/src/main/java/org/jabref/gui/util/BackgroundTask.java index c07f3b70485..f3f2cd24d09 100644 --- a/src/main/java/org/jabref/gui/util/BackgroundTask.java +++ b/src/main/java/org/jabref/gui/util/BackgroundTask.java @@ -233,7 +233,7 @@ public BackgroundTask withInitialMessage(String message) { return this; } - class BackgroundProgress { + static class BackgroundProgress { private final double workDone; private final double max; diff --git a/src/main/java/org/jabref/gui/util/CurrentThreadTaskExecutor.java b/src/main/java/org/jabref/gui/util/CurrentThreadTaskExecutor.java index a5f8ec393a1..e615225f715 100644 --- a/src/main/java/org/jabref/gui/util/CurrentThreadTaskExecutor.java +++ b/src/main/java/org/jabref/gui/util/CurrentThreadTaskExecutor.java @@ -74,7 +74,7 @@ public DelayTaskThrottler createThrottler(int delay) { return throttler; } - private class FailedFuture implements Future { + private static class FailedFuture implements Future { private final Throwable exception; FailedFuture(Throwable exception) { diff --git a/src/main/java/org/jabref/gui/util/IconValidationDecorator.java b/src/main/java/org/jabref/gui/util/IconValidationDecorator.java index ada1bf7ab21..2608c5c0663 100644 --- a/src/main/java/org/jabref/gui/util/IconValidationDecorator.java +++ b/src/main/java/org/jabref/gui/util/IconValidationDecorator.java @@ -1,7 +1,7 @@ package org.jabref.gui.util; -import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import javafx.geometry.Pos; import javafx.scene.Node; @@ -61,6 +61,6 @@ protected Tooltip createTooltip(ValidationMessage message) { @Override protected Collection createValidationDecorations(ValidationMessage message) { - return Arrays.asList(new GraphicDecoration(createDecorationNode(message), position)); + return Collections.singletonList(new GraphicDecoration(createDecorationNode(message), position)); } } diff --git a/src/main/java/org/jabref/gui/util/component/TagBar.java b/src/main/java/org/jabref/gui/util/component/TagBar.java index 3c7161ae05d..3265567869b 100644 --- a/src/main/java/org/jabref/gui/util/component/TagBar.java +++ b/src/main/java/org/jabref/gui/util/component/TagBar.java @@ -56,7 +56,7 @@ public ObservableList getTags() { } public void setTags(Collection newTags) { - this.tags.setAll(tags); + this.tags.setAll(newTags); } public ListProperty tagsProperty() { diff --git a/src/main/java/org/jabref/logic/bibtex/comparator/FieldComparator.java b/src/main/java/org/jabref/logic/bibtex/comparator/FieldComparator.java index f0f4912780a..005ef6577ee 100644 --- a/src/main/java/org/jabref/logic/bibtex/comparator/FieldComparator.java +++ b/src/main/java/org/jabref/logic/bibtex/comparator/FieldComparator.java @@ -130,13 +130,13 @@ public int compare(BibEntry e1, BibEntry e2) { // Ok, parsing was successful. Update f1 and f2: return i1.get().compareTo(i2.get()) * multiplier; } else if (i1.isPresent()) { - // The first one was parseable, but not the second one. + // The first one was parsable, but not the second one. // This means we consider one < two return -1 * multiplier; } else if (i2.isPresent()) { - // The second one was parseable, but not the first one. + // The second one was parsable, but not the first one. // This means we consider one > two - return 1 * multiplier; + return multiplier; } // Else none of them were parseable, and we can fall back on comparing strings. } diff --git a/src/main/java/org/jabref/logic/bst/VM.java b/src/main/java/org/jabref/logic/bst/VM.java index f3dce6d5cfb..7b120710e1b 100644 --- a/src/main/java/org/jabref/logic/bst/VM.java +++ b/src/main/java/org/jabref/logic/bst/VM.java @@ -510,7 +510,7 @@ private VM(CommonTree tree) { */ buildInFunctions.put("stack$", context -> { while (!stack.empty()) { - LOGGER.debug("Stack entry", stack.pop()); + LOGGER.debug("Stack entry {}", stack.pop()); } }); @@ -574,7 +574,7 @@ private VM(CommonTree tree) { /* * Pops and prints the top of the stack to the log file. It's useful for debugging. */ - buildInFunctions.put("top$", context -> LOGGER.debug("Stack entry", stack.pop())); + buildInFunctions.put("top$", context -> LOGGER.debug("Stack entry {}", stack.pop())); /* * Pushes the current entry's type (book, article, etc.), but pushes diff --git a/src/main/java/org/jabref/logic/cleanup/Cleanups.java b/src/main/java/org/jabref/logic/cleanup/Cleanups.java index 7a9e510c7b7..29c4ffb24be 100644 --- a/src/main/java/org/jabref/logic/cleanup/Cleanups.java +++ b/src/main/java/org/jabref/logic/cleanup/Cleanups.java @@ -36,15 +36,13 @@ public class Cleanups { defaultFormatters.add(new FieldFormatterCleanup(InternalField.INTERNAL_ALL_TEXT_FIELDS_FIELD, new ReplaceUnicodeLigaturesFormatter())); DEFAULT_SAVE_ACTIONS = new FieldFormatterCleanups(false, defaultFormatters); - List recommendedBibTeXFormatters = new ArrayList<>(); - recommendedBibTeXFormatters.addAll(defaultFormatters); + List recommendedBibTeXFormatters = new ArrayList<>(defaultFormatters); recommendedBibTeXFormatters.add(new FieldFormatterCleanup(InternalField.INTERNAL_ALL_TEXT_FIELDS_FIELD, new HtmlToLatexFormatter())); recommendedBibTeXFormatters.add(new FieldFormatterCleanup(InternalField.INTERNAL_ALL_TEXT_FIELDS_FIELD, new UnicodeToLatexFormatter())); recommendedBibTeXFormatters.add(new FieldFormatterCleanup(InternalField.INTERNAL_ALL_TEXT_FIELDS_FIELD, new OrdinalsToSuperscriptFormatter())); RECOMMEND_BIBTEX_ACTIONS = new FieldFormatterCleanups(false, recommendedBibTeXFormatters); - List recommendedBiblatexFormatters = new ArrayList<>(); - recommendedBiblatexFormatters.addAll(defaultFormatters); + List recommendedBiblatexFormatters = new ArrayList<>(defaultFormatters); recommendedBiblatexFormatters.add(new FieldFormatterCleanup(StandardField.TITLE, new HtmlToUnicodeFormatter())); recommendedBiblatexFormatters.add(new FieldFormatterCleanup(InternalField.INTERNAL_ALL_TEXT_FIELDS_FIELD, new LatexToUnicodeFormatter())); // DO NOT ADD OrdinalsToSuperscriptFormatter here, because this causes issues. See https://github.com/JabRef/jabref/issues/2596. diff --git a/src/main/java/org/jabref/logic/exporter/BibTeXMLExporter.java b/src/main/java/org/jabref/logic/exporter/BibTeXMLExporter.java index 1e5b6b310ca..db32ced0e5d 100644 --- a/src/main/java/org/jabref/logic/exporter/BibTeXMLExporter.java +++ b/src/main/java/org/jabref/logic/exporter/BibTeXMLExporter.java @@ -211,7 +211,7 @@ private void parse(T entryType, BibEntry bibEntry, Entry entry) { try { method.invoke(entryType, new BigInteger(value)); } catch (NumberFormatException exception) { - LOGGER.warn("The value %s of the 'number' field is not an integer and thus is ignored for the export", value); + LOGGER.warn("The value {} of the 'number' field is not an integer and thus is ignored for the export", value); } break; } else if (StandardField.MONTH.equals(key)) { diff --git a/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java b/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java index 5876ee29ee1..49c77414794 100644 --- a/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java +++ b/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java @@ -65,7 +65,7 @@ public static Map getSerializedStringMap(MetaData metaData, StringBuilder value = new StringBuilder(); value.append(OS.NEWLINE); for (String line: entry.getValue()) { - value.append(line.replaceAll(";", "\\\\;") + MetaData.SEPARATOR_STRING + OS.NEWLINE); + value.append(line.replaceAll(";", "\\\\;")).append(MetaData.SEPARATOR_STRING).append(OS.NEWLINE); } serializedMetaData.put(entry.getKey(), value.toString()); } diff --git a/src/main/java/org/jabref/logic/exporter/TemplateExporter.java b/src/main/java/org/jabref/logic/exporter/TemplateExporter.java index 3b04572b50b..07ad310456e 100644 --- a/src/main/java/org/jabref/logic/exporter/TemplateExporter.java +++ b/src/main/java/org/jabref/logic/exporter/TemplateExporter.java @@ -14,6 +14,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.StringJoiner; import java.util.regex.Pattern; import org.jabref.logic.layout.Layout; @@ -247,7 +248,7 @@ public void export(final BibDatabaseContext databaseContext, final Path file, if (defLayout != null) { missingFormatters.addAll(defLayout.getMissingFormatters()); if (!missingFormatters.isEmpty()) { - LOGGER.warn("Missing formatters found ", missingFormatters); + LOGGER.warn("Missing formatters found: {}", missingFormatters); } } Map layouts = new HashMap<>(); @@ -310,10 +311,10 @@ public void export(final BibDatabaseContext databaseContext, final Path file, // Clear custom name formatters: layoutPreferences.clearCustomExportNameFormatters(); - if (!missingFormatters.isEmpty()) { + if (!missingFormatters.isEmpty() && LOGGER.isWarnEnabled()) { StringBuilder sb = new StringBuilder("The following formatters could not be found: "); sb.append(String.join(", ", missingFormatters)); - LOGGER.warn("Formatters not found", sb); + LOGGER.warn("Formatters {} not found", sb.toString()); } } } diff --git a/src/main/java/org/jabref/logic/importer/ImportFormatReader.java b/src/main/java/org/jabref/logic/importer/ImportFormatReader.java index aa7e0207e7d..4cf33ab3f13 100644 --- a/src/main/java/org/jabref/logic/importer/ImportFormatReader.java +++ b/src/main/java/org/jabref/logic/importer/ImportFormatReader.java @@ -71,9 +71,7 @@ public void resetImportFormats(ImportFormatPreferences newImportFormatPreference formats.add(new SilverPlatterImporter()); // Get custom import formats - for (CustomImporter importer : importFormatPreferences.getCustomImportList()) { - formats.add(importer); - } + formats.addAll(importFormatPreferences.getCustomImportList()); } /** diff --git a/src/main/java/org/jabref/logic/importer/fileformat/MrDLibImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/MrDLibImporter.java index fcc72396631..4924b1f50f0 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/MrDLibImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/MrDLibImporter.java @@ -91,7 +91,7 @@ private String convertToString(BufferedReader input) throws IOException { /** * Small pair-class to ensure the right order of the recommendations. */ - private class RankedBibEntry { + private static class RankedBibEntry { public BibEntry entry; public Integer rank; diff --git a/src/main/java/org/jabref/logic/layout/format/RTFChars.java b/src/main/java/org/jabref/logic/layout/format/RTFChars.java index 61945a01d51..e9d58e32a6d 100644 --- a/src/main/java/org/jabref/logic/layout/format/RTFChars.java +++ b/src/main/java/org/jabref/logic/layout/format/RTFChars.java @@ -15,7 +15,7 @@ * * 1.) Remove LaTeX-Command sequences. * - * 2.) Replace LaTeX-Special chars with RTF aquivalents. + * 2.) Replace LaTeX-Special chars with RTF equivalents. * * 3.) Replace emph and textit and textbf with their RTF replacements. * diff --git a/src/main/java/org/jabref/logic/msbib/MSBibConverter.java b/src/main/java/org/jabref/logic/msbib/MSBibConverter.java index de99ce6d919..d07551d33ab 100644 --- a/src/main/java/org/jabref/logic/msbib/MSBibConverter.java +++ b/src/main/java/org/jabref/logic/msbib/MSBibConverter.java @@ -73,10 +73,10 @@ public static MSBibEntry convert(BibEntry entry) { entry.getLatexFreeField(StandardField.LANGUAGE) .ifPresent(lang -> result.fields.put("LCID", String.valueOf(MSBibMapping.getLCID(lang)))); StringBuilder sbNumber = new StringBuilder(); - entry.getLatexFreeField(StandardField.ISBN).ifPresent(isbn -> sbNumber.append(" ISBN: " + isbn)); - entry.getLatexFreeField(StandardField.ISSN).ifPresent(issn -> sbNumber.append(" ISSN: " + issn)); - entry.getLatexFreeField(new UnknownField("lccn")).ifPresent(lccn -> sbNumber.append("LCCN: " + lccn)); - entry.getLatexFreeField(StandardField.MR_NUMBER).ifPresent(mrnumber -> sbNumber.append(" MRN: " + mrnumber)); + entry.getLatexFreeField(StandardField.ISBN).ifPresent(isbn -> sbNumber.append(" ISBN: ").append(isbn)); + entry.getLatexFreeField(StandardField.ISSN).ifPresent(issn -> sbNumber.append(" ISSN: ").append(issn)); + entry.getLatexFreeField(new UnknownField("lccn")).ifPresent(lccn -> sbNumber.append("LCCN: ").append(lccn)); + entry.getLatexFreeField(StandardField.MR_NUMBER).ifPresent(mrnumber -> sbNumber.append(" MRN: ").append(mrnumber)); result.standardNumber = sbNumber.toString(); if (result.standardNumber.isEmpty()) { diff --git a/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java b/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java index 5ca89ec4009..6a5302e8d7f 100644 --- a/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java +++ b/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java @@ -5,6 +5,7 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.stream.Collectors; @@ -67,7 +68,7 @@ private static List findWindowsOpenOfficeDirs() { } private static List findOSXOpenOfficeDirs() { - List sourceList = Arrays.asList(Paths.get("/Applications")); + List sourceList = Collections.singletonList(Paths.get("/Applications")); return findOpenOfficeDirectories(sourceList); } From 1c125d6c50b5b04b92fb2a9b69c09636ce963c93 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 29 Mar 2020 22:14:32 +0200 Subject: [PATCH 2/3] Fix checkstyle --- src/main/java/org/jabref/logic/exporter/TemplateExporter.java | 1 - src/main/java/org/jabref/logic/importer/ImportFormatReader.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/main/java/org/jabref/logic/exporter/TemplateExporter.java b/src/main/java/org/jabref/logic/exporter/TemplateExporter.java index 07ad310456e..3d95d91a3da 100644 --- a/src/main/java/org/jabref/logic/exporter/TemplateExporter.java +++ b/src/main/java/org/jabref/logic/exporter/TemplateExporter.java @@ -14,7 +14,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.StringJoiner; import java.util.regex.Pattern; import org.jabref.logic.layout.Layout; diff --git a/src/main/java/org/jabref/logic/importer/ImportFormatReader.java b/src/main/java/org/jabref/logic/importer/ImportFormatReader.java index 4cf33ab3f13..2f56dffd0ad 100644 --- a/src/main/java/org/jabref/logic/importer/ImportFormatReader.java +++ b/src/main/java/org/jabref/logic/importer/ImportFormatReader.java @@ -12,7 +12,6 @@ import org.jabref.logic.importer.fileformat.BiblioscapeImporter; import org.jabref.logic.importer.fileformat.BibtexImporter; import org.jabref.logic.importer.fileformat.CopacImporter; -import org.jabref.logic.importer.fileformat.CustomImporter; import org.jabref.logic.importer.fileformat.EndnoteImporter; import org.jabref.logic.importer.fileformat.EndnoteXmlImporter; import org.jabref.logic.importer.fileformat.InspecImporter; From 477fa0b3086cacf5e597ecdb00a3ae6a093ad103 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 30 Mar 2020 12:31:49 +0200 Subject: [PATCH 3/3] Revert partially "Fix some IntelliJ findings" This partially reverts commit 167558dfe1aaa090e57b9bae672e40a76a78abd0. --- src/main/java/org/jabref/JabRefGUI.java | 10 +++++----- src/main/java/org/jabref/gui/BasePanel.java | 2 +- .../gui/fieldeditors/contextmenu/CaseChangeMenu.java | 3 ++- src/main/java/org/jabref/logic/cleanup/Cleanups.java | 6 ++++-- .../org/jabref/logic/exporter/MetaDataSerializer.java | 2 +- .../java/org/jabref/logic/msbib/MSBibConverter.java | 8 ++++---- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/jabref/JabRefGUI.java b/src/main/java/org/jabref/JabRefGUI.java index 688227ce923..19be513cf87 100644 --- a/src/main/java/org/jabref/JabRefGUI.java +++ b/src/main/java/org/jabref/JabRefGUI.java @@ -215,11 +215,11 @@ private void debugLogWindowState(Stage mainStage) { if (LOGGER.isDebugEnabled()) { StringBuilder debugLogString = new StringBuilder(); debugLogString.append("SCREEN DATA:"); - debugLogString.append("mainStage.WINDOW_MAXIMISED: ").append(mainStage.isMaximized()).append("\n"); - debugLogString.append("mainStage.POS_X: ").append(mainStage.getX()).append("\n"); - debugLogString.append("mainStage.POS_Y: ").append(mainStage.getY()).append("\n"); - debugLogString.append("mainStage.SIZE_X: ").append(mainStage.getWidth()).append("\n"); - debugLogString.append("mainStages.SIZE_Y: ").append(mainStage.getHeight()).append("\n"); + debugLogString.append("mainStage.WINDOW_MAXIMISED: " + mainStage.isMaximized() + "\n"); + debugLogString.append("mainStage.POS_X: " + mainStage.getX() + "\n"); + debugLogString.append("mainStage.POS_Y: " + mainStage.getY() + "\n"); + debugLogString.append("mainStage.SIZE_X: " + mainStage.getWidth() + "\n"); + debugLogString.append("mainStages.SIZE_Y: " + mainStage.getHeight() + "\n"); LOGGER.debug(debugLogString.toString()); } } diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java index 30ced2ae877..934f93c8133 100644 --- a/src/main/java/org/jabref/gui/BasePanel.java +++ b/src/main/java/org/jabref/gui/BasePanel.java @@ -164,7 +164,7 @@ public String getTabTitle() { } } } else if (databaseLocation == DatabaseLocation.SHARED) { - title.append(this.bibDatabaseContext.getDBMSSynchronizer().getDBName()).append(" [").append(Localization.lang("shared")).append("]"); + title.append(this.bibDatabaseContext.getDBMSSynchronizer().getDBName() + " [" + Localization.lang("shared") + "]"); } return title.toString(); diff --git a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/CaseChangeMenu.java b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/CaseChangeMenu.java index 04961cabd06..6539516b776 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/CaseChangeMenu.java +++ b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/CaseChangeMenu.java @@ -23,7 +23,8 @@ public CaseChangeMenu(final StringProperty text) { Objects.requireNonNull(text); // create menu items, one for each case changer - List caseChangers = new ArrayList<>(Formatters.getCaseChangers()); + List caseChangers = new ArrayList<>(); + caseChangers.addAll(Formatters.getCaseChangers()); caseChangers.add(new ProtectTermsFormatter(Globals.protectedTermsLoader)); for (final Formatter caseChanger : caseChangers) { CustomMenuItem menuItem = new CustomMenuItem(new Label(caseChanger.getName())); diff --git a/src/main/java/org/jabref/logic/cleanup/Cleanups.java b/src/main/java/org/jabref/logic/cleanup/Cleanups.java index 29c4ffb24be..7a9e510c7b7 100644 --- a/src/main/java/org/jabref/logic/cleanup/Cleanups.java +++ b/src/main/java/org/jabref/logic/cleanup/Cleanups.java @@ -36,13 +36,15 @@ public class Cleanups { defaultFormatters.add(new FieldFormatterCleanup(InternalField.INTERNAL_ALL_TEXT_FIELDS_FIELD, new ReplaceUnicodeLigaturesFormatter())); DEFAULT_SAVE_ACTIONS = new FieldFormatterCleanups(false, defaultFormatters); - List recommendedBibTeXFormatters = new ArrayList<>(defaultFormatters); + List recommendedBibTeXFormatters = new ArrayList<>(); + recommendedBibTeXFormatters.addAll(defaultFormatters); recommendedBibTeXFormatters.add(new FieldFormatterCleanup(InternalField.INTERNAL_ALL_TEXT_FIELDS_FIELD, new HtmlToLatexFormatter())); recommendedBibTeXFormatters.add(new FieldFormatterCleanup(InternalField.INTERNAL_ALL_TEXT_FIELDS_FIELD, new UnicodeToLatexFormatter())); recommendedBibTeXFormatters.add(new FieldFormatterCleanup(InternalField.INTERNAL_ALL_TEXT_FIELDS_FIELD, new OrdinalsToSuperscriptFormatter())); RECOMMEND_BIBTEX_ACTIONS = new FieldFormatterCleanups(false, recommendedBibTeXFormatters); - List recommendedBiblatexFormatters = new ArrayList<>(defaultFormatters); + List recommendedBiblatexFormatters = new ArrayList<>(); + recommendedBiblatexFormatters.addAll(defaultFormatters); recommendedBiblatexFormatters.add(new FieldFormatterCleanup(StandardField.TITLE, new HtmlToUnicodeFormatter())); recommendedBiblatexFormatters.add(new FieldFormatterCleanup(InternalField.INTERNAL_ALL_TEXT_FIELDS_FIELD, new LatexToUnicodeFormatter())); // DO NOT ADD OrdinalsToSuperscriptFormatter here, because this causes issues. See https://github.com/JabRef/jabref/issues/2596. diff --git a/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java b/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java index 49c77414794..5876ee29ee1 100644 --- a/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java +++ b/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java @@ -65,7 +65,7 @@ public static Map getSerializedStringMap(MetaData metaData, StringBuilder value = new StringBuilder(); value.append(OS.NEWLINE); for (String line: entry.getValue()) { - value.append(line.replaceAll(";", "\\\\;")).append(MetaData.SEPARATOR_STRING).append(OS.NEWLINE); + value.append(line.replaceAll(";", "\\\\;") + MetaData.SEPARATOR_STRING + OS.NEWLINE); } serializedMetaData.put(entry.getKey(), value.toString()); } diff --git a/src/main/java/org/jabref/logic/msbib/MSBibConverter.java b/src/main/java/org/jabref/logic/msbib/MSBibConverter.java index d07551d33ab..de99ce6d919 100644 --- a/src/main/java/org/jabref/logic/msbib/MSBibConverter.java +++ b/src/main/java/org/jabref/logic/msbib/MSBibConverter.java @@ -73,10 +73,10 @@ public static MSBibEntry convert(BibEntry entry) { entry.getLatexFreeField(StandardField.LANGUAGE) .ifPresent(lang -> result.fields.put("LCID", String.valueOf(MSBibMapping.getLCID(lang)))); StringBuilder sbNumber = new StringBuilder(); - entry.getLatexFreeField(StandardField.ISBN).ifPresent(isbn -> sbNumber.append(" ISBN: ").append(isbn)); - entry.getLatexFreeField(StandardField.ISSN).ifPresent(issn -> sbNumber.append(" ISSN: ").append(issn)); - entry.getLatexFreeField(new UnknownField("lccn")).ifPresent(lccn -> sbNumber.append("LCCN: ").append(lccn)); - entry.getLatexFreeField(StandardField.MR_NUMBER).ifPresent(mrnumber -> sbNumber.append(" MRN: ").append(mrnumber)); + entry.getLatexFreeField(StandardField.ISBN).ifPresent(isbn -> sbNumber.append(" ISBN: " + isbn)); + entry.getLatexFreeField(StandardField.ISSN).ifPresent(issn -> sbNumber.append(" ISSN: " + issn)); + entry.getLatexFreeField(new UnknownField("lccn")).ifPresent(lccn -> sbNumber.append("LCCN: " + lccn)); + entry.getLatexFreeField(StandardField.MR_NUMBER).ifPresent(mrnumber -> sbNumber.append(" MRN: " + mrnumber)); result.standardNumber = sbNumber.toString(); if (result.standardNumber.isEmpty()) {