diff --git a/build.gradle b/build.gradle index 5e228b7db91..d9ec3cb6654 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,7 @@ plugins { id 'idea' - id 'org.openrewrite.rewrite' version '6.29.0' + id 'org.openrewrite.rewrite' version '6.29.3' id "org.itsallcode.openfasttrace" version "3.0.1" } @@ -401,7 +401,7 @@ dependencies { xjc group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: '3.0.2' xjc group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '3.0.2' - rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.22.0")) + rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.23.2")) rewrite("org.openrewrite.recipe:rewrite-static-analysis") rewrite("org.openrewrite.recipe:rewrite-logging-frameworks") rewrite("org.openrewrite.recipe:rewrite-testing-frameworks") diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternsPanel.java b/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternsPanel.java index 1c234329b76..11e16797446 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternsPanel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternsPanel.java @@ -124,7 +124,7 @@ public void updateItem(CitationKeyPatternsPanelItemModel item, boolean empty) { setStyle(""); } else if (isSelected()) { setStyle("-fx-background-color: -fx-selection-bar"); - } else if (item.getEntryType().getName().equals(CitationKeyPatternsPanelViewModel.ENTRY_TYPE_DEFAULT_NAME)) { + } else if (CitationKeyPatternsPanelViewModel.ENTRY_TYPE_DEFAULT_NAME.equals(item.getEntryType().getName())) { setStyle("-fx-background-color: -fx-default-button"); } else { setStyle(""); diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternsPanelViewModel.java b/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternsPanelViewModel.java index 7a0c98f4cd8..78df89b5ba7 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternsPanelViewModel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternsPanelViewModel.java @@ -26,9 +26,9 @@ public class CitationKeyPatternsPanelViewModel { if (itemOneName.equals(itemTwoName)) { return 0; - } else if (itemOneName.equals(ENTRY_TYPE_DEFAULT_NAME)) { + } else if (ENTRY_TYPE_DEFAULT_NAME.equals(itemOneName)) { return -1; - } else if (itemTwoName.equals(ENTRY_TYPE_DEFAULT_NAME)) { + } else if (ENTRY_TYPE_DEFAULT_NAME.equals(itemTwoName)) { return 1; } diff --git a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java index 4a79e57b45c..6946b5997ee 100644 --- a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java +++ b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java @@ -205,7 +205,7 @@ public static Set fromString(String storedFileTypes) { // Read the prefs information for file types: String[][] vals = StringUtil.decodeStringDoubleArray(storedFileTypes); for (String[] val : vals) { - if ((val.length == 2) && val[1].equals(FILE_TYPE_REMOVED_FLAG)) { + if ((val.length == 2) && FILE_TYPE_REMOVED_FLAG.equals(val[1])) { // This entry indicates that a default entry type should be removed: ExternalFileType toRemove = null; for (ExternalFileType type : types) { diff --git a/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java b/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java index 33640a4d1a7..dd8ef20c091 100644 --- a/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java @@ -403,7 +403,7 @@ public void setValues() { if (parentNode != null) { parentNode.getGroup() .getIconName() - .filter(iconName -> !iconName.equals(DefaultGroupsFactory.ALL_ENTRIES_GROUP_DEFAULT_ICON)) + .filter(iconName -> !DefaultGroupsFactory.ALL_ENTRIES_GROUP_DEFAULT_ICON.equals(iconName)) .ifPresent(iconProperty::setValue); parentNode.getGroup().getColor().ifPresent(color -> colorUseProperty.setValue(true)); } diff --git a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java index 06907a2bcb8..46183d7f62b 100644 --- a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java @@ -147,7 +147,7 @@ public void setValues() { catalogs.addAll(WebFetchers.getSearchBasedFetchers(importFormatPreferences, importerPreferences) .stream() .map(SearchBasedFetcher::getName) - .filter(name -> !name.equals(CompositeSearchBasedFetcher.FETCHER_NAME)) + .filter(name -> !CompositeSearchBasedFetcher.FETCHER_NAME.equals(name)) .map(name -> { boolean enabled = importerPreferences.getCatalogs().contains(name); return new StudyCatalogItem(name, enabled); diff --git a/src/main/java/org/jabref/gui/slr/ManageStudyDefinitionViewModel.java b/src/main/java/org/jabref/gui/slr/ManageStudyDefinitionViewModel.java index 8080c64990a..c1dade283be 100644 --- a/src/main/java/org/jabref/gui/slr/ManageStudyDefinitionViewModel.java +++ b/src/main/java/org/jabref/gui/slr/ManageStudyDefinitionViewModel.java @@ -75,7 +75,7 @@ public ManageStudyDefinitionViewModel(ImportFormatPreferences importFormatPrefer .map(SearchBasedFetcher::getName) // The user wants to select specific fetchers // The fetcher summarizing ALL fetchers can be emulated by selecting ALL fetchers (which happens rarely when doing an SLR) - .filter(name -> !name.equals(CompositeSearchBasedFetcher.FETCHER_NAME)) + .filter(name -> !CompositeSearchBasedFetcher.FETCHER_NAME.equals(name)) .map(name -> { boolean enabled = DEFAULT_SELECTION.contains(name); return new StudyCatalogItem(name, enabled); @@ -108,7 +108,7 @@ public ManageStudyDefinitionViewModel(Study study, .map(SearchBasedFetcher::getName) // The user wants to select specific fetchers // The fetcher summarizing ALL fetchers can be emulated by selecting ALL fetchers (which happens rarely when doing an SLR) - .filter(name -> !name.equals(CompositeSearchBasedFetcher.FETCHER_NAME)) + .filter(name -> !CompositeSearchBasedFetcher.FETCHER_NAME.equals(name)) .map(name -> { boolean enabled = studyDatabases.contains(new StudyDatabase(name, true)); return new StudyCatalogItem(name, enabled); diff --git a/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java b/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java index 85a4ecfd8e0..f9755996beb 100644 --- a/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java +++ b/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java @@ -98,7 +98,7 @@ private static Map serializeMetaData(Map> s continue; } - boolean isSaveActions = metaItem.getKey().equals(MetaData.SAVE_ACTIONS); + boolean isSaveActions = MetaData.SAVE_ACTIONS.equals(metaItem.getKey()); // The last "MetaData.SEPARATOR_STRING" adds compatibility to JabRef v5.9 and earlier StringJoiner joiner = new StringJoiner(MetaData.SEPARATOR_STRING, "", MetaData.SEPARATOR_STRING); boolean lastWasSaveActionsEnablement = false; diff --git a/src/main/java/org/jabref/logic/exporter/XmpExporter.java b/src/main/java/org/jabref/logic/exporter/XmpExporter.java index 23730852ee0..3cb88848a06 100644 --- a/src/main/java/org/jabref/logic/exporter/XmpExporter.java +++ b/src/main/java/org/jabref/logic/exporter/XmpExporter.java @@ -47,7 +47,7 @@ public void export(BibDatabaseContext databaseContext, Path file, List // This is a distinction between writing all entries from the supplied list to a single .xmp file, // or write every entry to a separate file. - if (file.getFileName().toString().trim().equals(XMP_SPLIT_DIRECTORY_INDICATOR)) { + if (XMP_SPLIT_DIRECTORY_INDICATOR.equals(file.getFileName().toString().trim())) { for (BibEntry entry : entries) { // Avoid situations, where two citation keys are null Path entryFile; diff --git a/src/main/java/org/jabref/logic/importer/fetcher/DoiFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/DoiFetcher.java index 2aa9305a869..b06068169ad 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/DoiFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/DoiFetcher.java @@ -244,6 +244,6 @@ private boolean isAPSJournal(BibEntry entry, String doiAsString) { } String suffix = doiAsString.substring(doiAsString.lastIndexOf('/') + 1); String organizationId = doiAsString.substring(doiAsString.indexOf('.') + 1, doiAsString.indexOf('/')); - return organizationId.equals(APS_JOURNAL_ORG_DOI_ID) && APS_SUFFIX_PATTERN.matcher(suffix).matches(); + return APS_JOURNAL_ORG_DOI_ID.equals(organizationId) && APS_SUFFIX_PATTERN.matcher(suffix).matches(); } } diff --git a/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java b/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java index ebb1282a787..adf2f95ef77 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java @@ -212,7 +212,7 @@ private void parseDatabaseID() throws IOException { skipWhitespace(); String label = parseTextToken().trim(); - if (label.equals(BibtexDatabaseWriter.DATABASE_ID_PREFIX)) { + if (BibtexDatabaseWriter.DATABASE_ID_PREFIX.equals(label)) { skipWhitespace(); database.setSharedDatabaseID(parseTextToken().trim()); } @@ -354,7 +354,7 @@ private void parseJabRefComment(Map meta) { // We remove all line breaks in the metadata // These have been inserted to prevent too long lines when the file was saved, and are not part of the data. String comment = buffer.toString().replaceAll("[\\x0d\\x0a]", ""); - if (comment.substring(0, Math.min(comment.length(), MetaData.META_FLAG.length())).equals(MetaData.META_FLAG)) { + if (MetaData.META_FLAG.equals(comment.substring(0, Math.min(comment.length(), MetaData.META_FLAG.length())))) { if (comment.startsWith(MetaData.META_FLAG)) { String rest = comment.substring(MetaData.META_FLAG.length()); @@ -367,8 +367,8 @@ private void parseJabRefComment(Map meta) { dumpTextReadSoFarToString(); } } - } else if (comment.substring(0, Math.min(comment.length(), MetaData.ENTRYTYPE_FLAG.length())) - .equals(MetaData.ENTRYTYPE_FLAG)) { + } else if (MetaData.ENTRYTYPE_FLAG + .equals(comment.substring(0, Math.min(comment.length(), MetaData.ENTRYTYPE_FLAG.length())))) { // A custom entry type can also be stored in a // "@comment" Optional typ = MetaDataParser.parseCustomEntryType(comment); diff --git a/src/main/java/org/jabref/logic/importer/util/MetaDataParser.java b/src/main/java/org/jabref/logic/importer/util/MetaDataParser.java index d1e66146412..d6bd258d283 100644 --- a/src/main/java/org/jabref/logic/importer/util/MetaDataParser.java +++ b/src/main/java/org/jabref/logic/importer/util/MetaDataParser.java @@ -119,7 +119,7 @@ public MetaData parse(MetaData metaData, Map data, Character key } else if (entry.getKey().startsWith(MetaData.SELECTOR_META_PREFIX)) { // edge case, it might be one special field e.g. article from biblatex-apa, but we can't distinguish this from any other field and rather prefer to handle it as UnknownField metaData.addContentSelector(ContentSelectors.parse(FieldFactory.parseField(entry.getKey().substring(MetaData.SELECTOR_META_PREFIX.length())), StringUtil.unquote(entry.getValue(), MetaData.ESCAPE_CHARACTER))); - } else if (entry.getKey().equals(MetaData.FILE_DIRECTORY)) { + } else if (MetaData.FILE_DIRECTORY.equals(entry.getKey())) { metaData.setLibrarySpecificFileDirectory(parseDirectory(entry.getValue())); } else if (entry.getKey().startsWith(MetaData.FILE_DIRECTORY + '-')) { // The user name starts directly after FILE_DIRECTORY + '-' @@ -130,26 +130,26 @@ public MetaData parse(MetaData metaData, Map data, Character key String user = entry.getKey().substring(MetaData.FILE_DIRECTORY_LATEX.length() + 1); Path path = Path.of(parseDirectory(entry.getValue())).normalize(); metaData.setLatexFileDirectory(user, path); - } else if (entry.getKey().equals(MetaData.SAVE_ACTIONS)) { + } else if (MetaData.SAVE_ACTIONS.equals(entry.getKey())) { metaData.setSaveActions(fieldFormatterCleanupsParse(values)); - } else if (entry.getKey().equals(MetaData.DATABASE_TYPE)) { + } else if (MetaData.DATABASE_TYPE.equals(entry.getKey())) { metaData.setMode(BibDatabaseMode.parse(getSingleItem(values))); - } else if (entry.getKey().equals(MetaData.KEYPATTERNDEFAULT)) { + } else if (MetaData.KEYPATTERNDEFAULT.equals(entry.getKey())) { defaultCiteKeyPattern = new CitationKeyPattern(getSingleItem(values)); - } else if (entry.getKey().equals(MetaData.PROTECTED_FLAG_META)) { + } else if (MetaData.PROTECTED_FLAG_META.equals(entry.getKey())) { if (Boolean.parseBoolean(getSingleItem(values))) { metaData.markAsProtected(); } else { metaData.markAsNotProtected(); } - } else if (entry.getKey().equals(MetaData.SAVE_ORDER_CONFIG)) { + } else if (MetaData.SAVE_ORDER_CONFIG.equals(entry.getKey())) { metaData.setSaveOrder(SaveOrder.parse(values)); - } else if (entry.getKey().equals(MetaData.GROUPSTREE) || entry.getKey().equals(MetaData.GROUPSTREE_LEGACY)) { + } else if (MetaData.GROUPSTREE.equals(entry.getKey()) || MetaData.GROUPSTREE_LEGACY.equals(entry.getKey())) { metaData.setGroups(GroupsParser.importGroups(values, keywordSeparator, fileMonitor, metaData)); - } else if (entry.getKey().equals(MetaData.GROUPS_SEARCH_SYNTAX_VERSION)) { + } else if (MetaData.GROUPS_SEARCH_SYNTAX_VERSION.equals(entry.getKey())) { Version version = Version.parse(getSingleItem(values)); metaData.setGroupSearchSyntaxVersion(version); - } else if (entry.getKey().equals(MetaData.VERSION_DB_STRUCT)) { + } else if (MetaData.VERSION_DB_STRUCT.equals(entry.getKey())) { metaData.setVersionDBStructure(getSingleItem(values)); } else { // Keep meta data items that we do not know in the file diff --git a/src/main/java/org/jabref/logic/integrity/EditionChecker.java b/src/main/java/org/jabref/logic/integrity/EditionChecker.java index 697ca38e85c..3fb6ec5b89b 100644 --- a/src/main/java/org/jabref/logic/integrity/EditionChecker.java +++ b/src/main/java/org/jabref/logic/integrity/EditionChecker.java @@ -40,7 +40,7 @@ public Optional checkValue(String value) { return Optional.empty(); } - if (value.equals(FIRST_EDITION)) { + if (FIRST_EDITION.equals(value)) { return Optional.of(Localization.lang("edition of book reported as just 1")); } diff --git a/src/main/java/org/jabref/logic/layout/Layout.java b/src/main/java/org/jabref/logic/layout/Layout.java index 65587b1f81b..8af843a1865 100644 --- a/src/main/java/org/jabref/logic/layout/Layout.java +++ b/src/main/java/org/jabref/logic/layout/Layout.java @@ -57,7 +57,7 @@ public Layout(List parsedEntries, tmpEntries.add(le); blockEntries = null; } else { - LOGGER.debug(blockStart + '\n' + parsedEntry.s); + LOGGER.debug("{}\n{}", blockStart, parsedEntry.s); LOGGER.warn("Nested field/group entries are not implemented!"); Thread.dumpStack(); } diff --git a/src/main/java/org/jabref/logic/shared/listener/PostgresSQLNotificationListener.java b/src/main/java/org/jabref/logic/shared/listener/PostgresSQLNotificationListener.java index 9d9d8819445..0c6db429622 100644 --- a/src/main/java/org/jabref/logic/shared/listener/PostgresSQLNotificationListener.java +++ b/src/main/java/org/jabref/logic/shared/listener/PostgresSQLNotificationListener.java @@ -36,7 +36,7 @@ public void run() { if (notifications != null) { for (PGNotification notification : notifications) { - if (!notification.getName().equals(DBMSProcessor.PROCESSOR_ID)) { + if (!DBMSProcessor.PROCESSOR_ID.equals(notification.getName())) { dbmsSynchronizer.pullChanges(); } } diff --git a/src/main/java/org/jabref/logic/util/Version.java b/src/main/java/org/jabref/logic/util/Version.java index 1380c90e109..245ee21031f 100644 --- a/src/main/java/org/jabref/logic/util/Version.java +++ b/src/main/java/org/jabref/logic/util/Version.java @@ -57,7 +57,7 @@ private static Logger getLogger() { * @return the parsed version or {@link Version#UNKNOWN_VERSION} if an error occurred */ public static Version parse(String version) { - if ((version == null) || version.isEmpty() || version.equals(BuildInfo.UNKNOWN_VERSION) + if ((version == null) || version.isEmpty() || BuildInfo.UNKNOWN_VERSION.equals(version) || "${version}".equals(version)) { return UNKNOWN_VERSION; } @@ -127,9 +127,9 @@ public boolean isNewerThan(Version otherVersion) { Objects.requireNonNull(otherVersion); if (Objects.equals(this, otherVersion)) { return false; - } else if (this.getFullVersion().equals(BuildInfo.UNKNOWN_VERSION)) { + } else if (BuildInfo.UNKNOWN_VERSION.equals(this.getFullVersion())) { return false; - } else if (otherVersion.getFullVersion().equals(BuildInfo.UNKNOWN_VERSION)) { + } else if (BuildInfo.UNKNOWN_VERSION.equals(otherVersion.getFullVersion())) { return false; } diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/migrations/PreferencesMigrations.java index b5a2ba9bbad..10d0eb4e30f 100644 --- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/org/jabref/migrations/PreferencesMigrations.java @@ -516,9 +516,9 @@ private static void upgradeCleanups(JabRefCliPreferences prefs) { List formatterCleanups = List.of(StringUtil.unifyLineBreaks(prefs.get(V5_8_CLEANUP_FIELD_FORMATTERS), "\n") .split("\n")); if (formatterCleanups.size() >= 2 - && (formatterCleanups.getFirst().equals(FieldFormatterCleanups.ENABLED) - || formatterCleanups.getFirst().equals(FieldFormatterCleanups.DISABLED))) { - prefs.putBoolean(V6_0_CLEANUP_FIELD_FORMATTERS_ENABLED, formatterCleanups.getFirst().equals(FieldFormatterCleanups.ENABLED) + && (FieldFormatterCleanups.ENABLED.equals(formatterCleanups.getFirst()) + || FieldFormatterCleanups.DISABLED.equals(formatterCleanups.getFirst()))) { + prefs.putBoolean(V6_0_CLEANUP_FIELD_FORMATTERS_ENABLED, FieldFormatterCleanups.ENABLED.equals(formatterCleanups.getFirst()) ? Boolean.TRUE : Boolean.FALSE); diff --git a/src/main/java/org/jabref/model/database/BibDatabaseContext.java b/src/main/java/org/jabref/model/database/BibDatabaseContext.java index f90a7c64fbd..2efba5d6c65 100644 --- a/src/main/java/org/jabref/model/database/BibDatabaseContext.java +++ b/src/main/java/org/jabref/model/database/BibDatabaseContext.java @@ -133,7 +133,7 @@ public boolean isBiblatexMode() { */ public boolean isStudy() { return this.getDatabasePath() - .map(path -> path.getFileName().toString().equals(Crawler.FILENAME_STUDY_RESULT_BIB) && + .map(path -> Crawler.FILENAME_STUDY_RESULT_BIB.equals(path.getFileName().toString()) && Files.exists(path.resolveSibling(StudyRepository.STUDY_DEFINITION_FILE_NAME))) .orElse(false); }