Skip to content

Add OpenRewrite changes#15665

Closed
InAnYan wants to merge 19 commits into
JabRef:mainfrom
InAnYan:refactor/open-rewrite-1
Closed

Add OpenRewrite changes#15665
InAnYan wants to merge 19 commits into
JabRef:mainfrom
InAnYan:refactor/open-rewrite-1

Conversation

@InAnYan

@InAnYan InAnYan commented May 3, 2026

Copy link
Copy Markdown
Member

Related issues and pull requests

Closes https://github.com/JabRef/jabref-issue-melting-pot/issues/1289

PR Description

As OpenRewrite check wasn't working properly, a lot of changes was accumulated. I run OpenRewrite on the current main and this is the PR.

Steps to test

  • Run rewriteDryRun.
  • Run checkstyle tests.

As a result, they all should be green.

Checklist

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • [/] I added screenshots in the PR description (if change is visible to the user)
  • [/] I added a screenshot in the PR description showing a library with a single entry with me as author and as title the issue number
  • [/] I described the change in CHANGELOG.md in a way that can be understood by the average user (if change is visible to the user)
  • I checked the user documentation for up to dateness and submitted a pull request to our user documentation repository

@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Apply OpenRewrite refactoring rules for code quality improvements

✨ Enhancement 🧪 Tests

Grey Divider

Walkthroughs

Description
• Applied OpenRewrite refactoring rules across the codebase to improve code quality and consistency
• **Removed unnecessary else blocks**: Simplified control flow in 200+ files by eliminating
  redundant else clauses after early returns and moving statements to top level
• **Replaced trim().isEmpty() with isBlank()**: Updated 40+ files to use the more concise and
  semantically correct String.isBlank() method
• **Used Predicate.not for cleaner filtering**: Added static imports and replaced lambda
  expressions like key -> !key.isEmpty() with not(String::isEmpty) in 15+ files
• **Converted to switch expressions**: Modernized code by converting imperative switch statements to
  switch expressions in select methods
• **Improved test annotations**: Changed @CsvSource to @ValueSource for parameterized tests with
  single values in 10+ test files
• **Fixed logic error**: Corrected ETA calculation in ProgressCounter.java by changing <= to <
  in duration comparison
• **Used compound assignment operators**: Replaced verbose assignments like `variable = variable +
  value with variable += value` in multiple files
• **Updated logging**: Converted string concatenation in logger calls to parameterized format
  strings for better performance
• **Modernized collection API**: Changed list.get(0) to list.getFirst() for better code clarity
• **Improved formatting**: Fixed indentation and spacing in method chaining and stream operations
  across multiple files
Diagram
flowchart LR
  A["Codebase<br/>with style issues"] -->|Remove else blocks| B["Simplified<br/>control flow"]
  A -->|Replace trim().isEmpty| C["Use isBlank<br/>method"]
  A -->|Replace lambdas| D["Use Predicate.not<br/>static import"]
  A -->|Update tests| E["Use ValueSource<br/>annotation"]
  A -->|Fix logic| F["Correct ETA<br/>calculation"]
  B --> G["Improved code<br/>quality"]
  C --> G
  D --> G
  E --> G
  F --> G
Loading

Grey Divider

File Changes

1. jablib/src/main/java/org/jabref/logic/citationkeypattern/BracketedPattern.java Formatting +18/-27

Simplify control flow by removing unnecessary else blocks

• Removed unnecessary else blocks by moving return statements outside conditional structures
• Simplified control flow in multiple methods handling pattern matching and field value extraction
• Improved code readability by reducing nesting levels

jablib/src/main/java/org/jabref/logic/citationkeypattern/BracketedPattern.java


2. jablib/src/main/java/org/jabref/model/entry/BibEntry.java ✨ Enhancement +27/-32

Use Predicate.not and simplify conditional structures

• Added static import for Predicate.not to replace lambda expressions
• Replaced key -> !key.isEmpty() with not(String::isEmpty) for cleaner predicate syntax
• Removed unnecessary else blocks and flattened conditional structures
• Improved code readability in getFieldLatexFree and genericGetFieldOrAlias methods

jablib/src/main/java/org/jabref/model/entry/BibEntry.java


3. jablib/src/main/java/org/jabref/logic/ai/AiPreferences.java Formatting +21/-29

Remove unnecessary else blocks in preference getters

• Removed unnecessary else blocks in multiple getter methods
• Flattened conditional structures for getEmbeddingModel, getTemperature,
 getContextWindowSize, and other preference getters
• Improved code readability by reducing nesting

jablib/src/main/java/org/jabref/logic/ai/AiPreferences.java


View more (261)
4. jablib/src/main/java/org/jabref/logic/search/query/SearchToSqlVisitor.java Formatting +28/-33

Simplify conditional structures in SQL query visitor

• Removed unnecessary else blocks in visitImplicitAndExpression method
• Simplified nested conditional logic in getFieldQueryNode method
• Improved indentation and control flow structure

jablib/src/main/java/org/jabref/logic/search/query/SearchToSqlVisitor.java


5. jablib/src/main/java/org/jabref/logic/util/strings/StringUtil.java ✨ Enhancement +17/-22

Use isBlank() and remove unnecessary else blocks

• Replaced lines[i].trim().isEmpty() with lines[i].isBlank() for cleaner blank checking
• Removed unnecessary else blocks in isInCurlyBrackets, isInSquareBrackets, and
 isInCitationMarks methods
• Simplified control flow in capitalizeFirst and quoteStringIfSpaceIsContained methods

jablib/src/main/java/org/jabref/logic/util/strings/StringUtil.java


6. jabgui/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java Formatting +8/-11

Simplify field editor selection logic

• Removed unnecessary else block in getForField method
• Flattened conditional structure for field editor selection logic
• Improved code readability by reducing nesting levels

jabgui/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java


7. jablib/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfContentImporter.java ✨ Enhancement +19/-23

Simplify control flow and use isBlank() method

• Replaced nested else with else if in streamlineNames method
• Changed lineIndex = lineIndex + 1 to lineIndex++ for conciseness
• Replaced trim().isEmpty() with isBlank() for cleaner blank checking
• Simplified conditional logic in author parsing

jablib/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfContentImporter.java


8. jablib/src/main/java/org/jabref/logic/layout/LayoutEntry.java Formatting +34/-37

Remove else blocks and use isBlank() method

• Removed unnecessary else block in handleFieldOrGroupStart method
• Replaced trim().isEmpty() with isBlank() for cleaner blank checking
• Flattened nested conditional structures

jablib/src/main/java/org/jabref/logic/layout/LayoutEntry.java


9. jabgui/src/main/java/org/jabref/gui/openoffice/OOBibBase.java Formatting +11/-16

Remove unnecessary else blocks and improve formatting

• Removed unnecessary else blocks in multiple methods
• Improved indentation in stream operations
• Simplified conditional logic in collectResults, styleIsRequired, and databaseIsRequired
 methods

jabgui/src/main/java/org/jabref/gui/openoffice/OOBibBase.java


10. jablib/src/main/java/org/jabref/logic/importer/fetcher/ArXivFetcher.java Formatting +5/-10

Remove unnecessary else blocks in ArXiv fetcher

• Removed unnecessary else blocks in multiple methods
• Simplified conditional structures in getAutomaticDoi, searchForEntry, and searchForEntryById
 methods
• Improved code readability

jablib/src/main/java/org/jabref/logic/importer/fetcher/ArXivFetcher.java


11. jablib/src/main/java/org/jabref/logic/importer/fetcher/ZbMATH.java Formatting +9/-10

Improve formatting and remove else block

• Improved indentation in method chaining and stream operations
• Removed unnecessary else block in getURLForEntry method
• Simplified conditional logic

jablib/src/main/java/org/jabref/logic/importer/fetcher/ZbMATH.java


12. jablib/src/main/java/org/jabref/logic/openoffice/style/OOPreFormatter.java ✨ Enhancement +13/-15

Convert to switch expression and remove else block

• Converted getHTMLTag method from imperative to switch expression
• Removed unnecessary else block and variable assignment
• Improved code clarity with switch expression syntax

jablib/src/main/java/org/jabref/logic/openoffice/style/OOPreFormatter.java


13. jablib/src/main/java/org/jabref/logic/importer/fetcher/GoogleScholar.java Formatting +14/-17

Remove unnecessary else blocks in Google Scholar fetcher

• Removed unnecessary else blocks in downloadEntry and performSearchPaged methods
• Flattened nested conditional structures
• Improved code readability

jablib/src/main/java/org/jabref/logic/importer/fetcher/GoogleScholar.java


14. jabgui/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java Formatting +3/-5

Remove else blocks and improve formatting

• Removed unnecessary else blocks in getExternalFileTypeByMimeType and
 getExternalFileTypeByLinkedFile methods
• Improved indentation in method chaining
• Simplified conditional logic

jabgui/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java


15. jablib/src/main/java/org/jabref/logic/openoffice/style/JStyleGetCitationMarker.java Formatting +15/-18

Remove else block and improve formatting

• Removed unnecessary else block in formatAuthorList method
• Improved indentation in conditional structures
• Simplified control flow logic

jablib/src/main/java/org/jabref/logic/openoffice/style/JStyleGetCitationMarker.java


16. jabgui/src/main/java/org/jabref/gui/entryeditor/OtherFieldsTab.java Formatting +5/-6

Remove else block and improve formatting

• Removed unnecessary else block in determineFieldsToShow method
• Improved indentation in stream operations
• Simplified conditional logic

jabgui/src/main/java/org/jabref/gui/entryeditor/OtherFieldsTab.java


17. jabgui/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java Formatting +7/-10

Remove unnecessary else blocks

• Removed unnecessary else blocks in multiple methods
• Simplified conditional logic in getDescriptionAndLink and getTruncatedDescriptionAndLink
 methods
• Improved code readability

jabgui/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java


18. jablib/src/main/java/org/jabref/model/TreeNode.java Formatting +13/-18

Remove unnecessary else blocks in TreeNode

• Removed unnecessary else blocks in multiple methods
• Simplified conditional structures in getIndexOfChild, getRelativeSibling, isAncestorOf, and
 getRoot methods
• Improved code readability

jablib/src/main/java/org/jabref/model/TreeNode.java


19. jablib/src/main/java/org/jabref/logic/importer/fileformat/CitaviXmlImporter.java ✨ Enhancement +7/-8

Use static import for Predicate.not

• Added static import for Predicate.not
• Replaced Predicate.not(String::isEmpty) with not(String::isEmpty) for consistency
• Removed unused import of Predicate
• Simplified filter expressions

jablib/src/main/java/org/jabref/logic/importer/fileformat/CitaviXmlImporter.java


20. jabgui/src/main/java/org/jabref/Launcher.java Formatting +10/-13

Remove unnecessary else blocks in Launcher

• Removed unnecessary else blocks in handleMultipleAppInstances method
• Simplified nested conditional structures
• Improved code readability

jabgui/src/main/java/org/jabref/Launcher.java


21. jabgui/src/main/java/org/jabref/gui/groups/GroupTreeView.java Formatting +9/-10

Use uppercase D for double literals and remove else

• Changed double literals from lowercase d to uppercase D (e.g., 60d to 60D)
• Removed unnecessary else block in lambda expression
• Improved code consistency

jabgui/src/main/java/org/jabref/gui/groups/GroupTreeView.java


22. jablib/src/main/java/org/jabref/logic/openoffice/style/JStyle.java ✨ Enhancement +9/-11

Remove else block and use isBlank() method

• Removed unnecessary else block in isUpToDate method
• Replaced trim().isEmpty() with isBlank() for cleaner blank checking
• Simplified conditional logic

jablib/src/main/java/org/jabref/logic/openoffice/style/JStyle.java


23. jablib/src/main/java/org/jabref/model/groups/GroupTreeNode.java Formatting +6/-11

Remove unnecessary else blocks in GroupTreeNode

• Removed unnecessary else blocks in multiple methods
• Simplified conditional structures in getContainingGroups, addEntriesToGroup,
 removeEntriesFromGroup, and containsGroup methods
• Improved code readability

jablib/src/main/java/org/jabref/model/groups/GroupTreeNode.java


24. jabkit/src/main/java/org/jabref/toolkit/commands/JabKit.java Formatting +12/-15

Remove unnecessary else blocks in JabKit

• Removed unnecessary else blocks in importFile methods
• Simplified nested conditional structures
• Improved code readability

jabkit/src/main/java/org/jabref/toolkit/commands/JabKit.java


25. jabgui/src/main/java/org/jabref/gui/preview/ClipboardContentGenerator.java Formatting +7/-9

Remove else block and use compound assignment

• Removed unnecessary else block in generate method
• Changed string concatenation from markdown = markdown + OS.NEWLINE to markdown += OS.NEWLINE
• Simplified conditional logic

jabgui/src/main/java/org/jabref/gui/preview/ClipboardContentGenerator.java


26. jablib/src/main/java/org/jabref/logic/importer/fileformat/RepecNepImporter.java ✨ Enhancement +3/-3

Use isBlank() method instead of trim().isEmpty()

• Replaced trim().isEmpty() with isBlank() for cleaner blank checking in multiple locations
• Improved code consistency

jablib/src/main/java/org/jabref/logic/importer/fileformat/RepecNepImporter.java


27. jablib/src/main/java/org/jabref/logic/bibtex/comparator/EntryComparator.java Formatting +3/-6

Remove unnecessary else blocks in comparator

• Removed unnecessary else blocks in multiple comparison methods
• Simplified conditional logic
• Improved code readability

jablib/src/main/java/org/jabref/logic/bibtex/comparator/EntryComparator.java


28. jablib/src/main/java/org/jabref/logic/layout/format/DocBookAuthorFormatter.java ✨ Enhancement +8/-6

Use Predicate.not for filter expressions

• Added static import for Predicate.not
• Replaced lambda expressions von -> !von.isEmpty() with not(String::isEmpty) for cleaner syntax
• Improved code consistency

jablib/src/main/java/org/jabref/logic/layout/format/DocBookAuthorFormatter.java


29. jablib/src/main/java/org/jabref/logic/importer/fetcher/citation/semanticscholar/PaperDetails.java Formatting +26/-27

Remove else block and simplify switch expression

• Removed unnecessary else block in getPublicationType method
• Simplified switch expression structure
• Improved code readability

jablib/src/main/java/org/jabref/logic/importer/fetcher/citation/semanticscholar/PaperDetails.java


30. jablib/src/test/java/org/jabref/logic/importer/fileformat/BibtexImporterTest.java 🧪 Tests +3/-3

Use ValueSource instead of CsvSource for single values

• Changed @CsvSource to @ValueSource for parameterized tests with single string values
• Improved test annotation usage

jablib/src/test/java/org/jabref/logic/importer/fileformat/BibtexImporterTest.java


31. jablib/src/main/java/org/jabref/logic/layout/format/Authors.java ✨ Enhancement +5/-3

Use Predicate.not and compound assignment operator

• Added static import for Predicate.not
• Replaced lambda expressions with not(String::isEmpty) for cleaner filter syntax
• Changed string concatenation from firstNameResult = firstNameResult + abbr.substring(3) to
 firstNameResult += abbr.substring(3)

jablib/src/main/java/org/jabref/logic/layout/format/Authors.java


32. jablib/src/main/java/org/jabref/logic/util/Version.java Formatting +18/-19

Remove else block and simplify control flow

• Removed unnecessary else block in getChangelogUrl method
• Flattened nested conditional structures
• Improved code readability

jablib/src/main/java/org/jabref/logic/util/Version.java


33. jabgui/src/main/java/org/jabref/gui/ai/components/aichat/chatprompt/ChatPromptComponent.java Formatting +6/-8

Remove else block and simplify conditional logic

• Removed unnecessary else block in listener lambda
• Simplified conditional logic with comment preservation
• Improved code readability

jabgui/src/main/java/org/jabref/gui/ai/components/aichat/chatprompt/ChatPromptComponent.java


34. jabgui/src/main/java/org/jabref/gui/externalfiles/ExternalFilesEntryLinker.java Formatting +3/-4

Improve formatting and remove else block

• Improved indentation in method chaining
• Removed unnecessary else block in linkFilesToEntry method
• Simplified conditional logic

jabgui/src/main/java/org/jabref/gui/externalfiles/ExternalFilesEntryLinker.java


35. jablib/src/main/java/org/jabref/logic/importer/fetcher/MedlineFetcher.java Formatting +13/-14

Remove else block and simplify control flow

• Removed unnecessary else block in performSearch method
• Flattened nested conditional structures
• Improved code readability

jablib/src/main/java/org/jabref/logic/importer/fetcher/MedlineFetcher.java


36. jablib/src/main/java/org/jabref/logic/importer/util/MetaDataParser.java Formatting +5/-8

Remove unnecessary else blocks in metadata parser

• Removed unnecessary else blocks in multiple methods
• Simplified conditional logic in parseDirectory, getSingleItem, and
 fieldFormatterCleanupsParse methods
• Improved code readability

jablib/src/main/java/org/jabref/logic/importer/util/MetaDataParser.java


37. jabgui/src/main/java/org/jabref/gui/edit/CopyMoreAction.java ✨ Enhancement +3/-1

Use Predicate.not for filter expressions

• Added static import for Predicate.not
• Replaced value -> !value.isEmpty() with not(String::isEmpty) for cleaner predicate syntax

jabgui/src/main/java/org/jabref/gui/edit/CopyMoreAction.java


38. jabgui/src/main/java/org/jabref/gui/ai/components/summary/SummaryComponent.java Formatting +2/-4

Remove unnecessary else blocks

• Removed unnecessary else blocks in multiple methods
• Simplified conditional logic
• Improved code readability

jabgui/src/main/java/org/jabref/gui/ai/components/summary/SummaryComponent.java


39. jablib/src/main/java/org/jabref/logic/push/PushToApplicationDetector.java ✨ Enhancement +5/-6

Use isBlank() and remove else block

• Replaced trim().isEmpty() with isBlank() for cleaner blank checking
• Removed unnecessary else block in isExecutableNameMatch method
• Simplified conditional logic

jablib/src/main/java/org/jabref/logic/push/PushToApplicationDetector.java


40. jablib/src/main/java/org/jabref/logic/integrity/BracesCorrector.java Formatting +13/-14

Remove else block and simplify control flow

• Removed unnecessary else block in apply method
• Flattened nested conditional structures
• Improved code readability

jablib/src/main/java/org/jabref/logic/integrity/BracesCorrector.java


41. jabgui/src/main/java/org/jabref/gui/libraryproperties/constants/ConstantsItemModel.java ✨ Enhancement +4/-6

Use isBlank() and remove else blocks

• Replaced trim().isEmpty() with isBlank() for cleaner blank checking
• Removed unnecessary else blocks in validation methods
• Simplified conditional logic

jabgui/src/main/java/org/jabref/gui/libraryproperties/constants/ConstantsItemModel.java


42. jablib/src/main/java/org/jabref/logic/msbib/MSBibConverter.java Formatting +8/-10

Remove else block and use else if chain

• Removed unnecessary else block and converted to multiple else if statements
• Simplified conditional logic in convert method
• Improved code readability

jablib/src/main/java/org/jabref/logic/msbib/MSBibConverter.java


43. jabgui/src/main/java/org/jabref/gui/fieldeditors/URLUtil.java Formatting +4/-9

Remove unnecessary else blocks

• Removed unnecessary else blocks in getSuffix method
• Simplified nested conditional structures
• Improved code readability

jabgui/src/main/java/org/jabref/gui/fieldeditors/URLUtil.java


44. jablib/src/main/java/org/jabref/logic/importer/fileformat/MedlinePlainImporter.java ✨ Enhancement +4/-6

Use isBlank() and remove else block

• Replaced trim().isEmpty() with isBlank() for cleaner blank checking
• Removed unnecessary else block in addTitles method
• Simplified conditional logic

jablib/src/main/java/org/jabref/logic/importer/fileformat/MedlinePlainImporter.java


45. jabgui/src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java Formatting +5/-7

Remove unnecessary else blocks

• Removed unnecessary else blocks in getName and getDisplayName methods
• Simplified conditional logic
• Improved code readability

jabgui/src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java


46. jablib/src/main/java/org/jabref/model/entry/BibEntryTypesManager.java Formatting +7/-9

Remove else blocks and improve formatting

• Removed unnecessary else blocks in multiple methods
• Improved indentation in stream operations
• Simplified conditional logic

jablib/src/main/java/org/jabref/model/entry/BibEntryTypesManager.java


47. jablib/src/main/java/org/jabref/logic/cleanup/TimestampToDateField.java Formatting +8/-9

Remove else block and simplify control flow

• Removed unnecessary else block in formatTimeStamp method
• Flattened nested conditional structures
• Improved code readability

jablib/src/main/java/org/jabref/logic/cleanup/TimestampToDateField.java


48. jablib/src/main/java/org/jabref/logic/importer/FetcherException.java Formatting +3/-6

Remove unnecessary else blocks in FetcherException

• Removed unnecessary else blocks in multiple methods
• Simplified conditional logic in getLocalizedMessage, getPrefix, and of methods
• Improved code readability

jablib/src/main/java/org/jabref/logic/importer/FetcherException.java


49. jablib/src/main/java/org/jabref/model/entry/Author.java Formatting +4/-7

Remove else block and simplify conditional logic

• Removed unnecessary else block in constructor
• Simplified conditional logic for family name formatting
• Improved code readability

jablib/src/main/java/org/jabref/model/entry/Author.java


50. jabgui/src/main/java/org/jabref/gui/importer/ImportCustomEntryTypesDialogViewModel.java Formatting +4/-6

Remove else block and use else if

• Removed unnecessary else block and converted to else if statement
• Simplified conditional logic
• Improved code readability

jabgui/src/main/java/org/jabref/gui/importer/ImportCustomEntryTypesDialogViewModel.java


51. jabgui/src/main/java/org/jabref/gui/libraryproperties/saving/SavingPropertiesViewModel.java Formatting +4/-6

Remove else block and use else if

• Removed unnecessary else block and converted to else if statement
• Simplified conditional logic in storeSettings method
• Improved code readability

jabgui/src/main/java/org/jabref/gui/libraryproperties/saving/SavingPropertiesViewModel.java


52. jabgui/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java Formatting +5/-6

Remove else block and improve formatting

• Removed unnecessary else block in lambda expression
• Improved indentation in stream operations
• Simplified conditional logic

jabgui/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java


53. jablib/src/main/java/org/jabref/logic/openoffice/style/OOFormatBibliography.java Formatting +9/-10

Remove else block and simplify control flow

• Removed unnecessary else block in formatBibliographyEntryBody method
• Flattened nested conditional structures
• Improved code readability

jablib/src/main/java/org/jabref/logic/openoffice/style/OOFormatBibliography.java


54. jabgui/src/main/java/org/jabref/gui/copyfiles/CopyLinkedFilesAction.java Formatting +3/-5

Remove else block and use else if

• Removed unnecessary else block and converted to else if statement
• Simplified conditional logic in execute method
• Improved code readability

jabgui/src/main/java/org/jabref/gui/copyfiles/CopyLinkedFilesAction.java


55. jablib/src/main/java/org/jabref/logic/importer/fetcher/LOBIDFetcher.java ✨ Enhancement +4/-2

Use Predicate.not for filter expressions

• Added static import for Predicate.not
• Replaced lambda expressions with not(String::isEmpty) for cleaner filter syntax

jablib/src/main/java/org/jabref/logic/importer/fetcher/LOBIDFetcher.java


56. jabgui/src/main/java/org/jabref/migrations/CustomEntryTypePreferenceMigration.java Formatting +7/-8

Remove else block and simplify control flow

• Removed unnecessary else block in getBibEntryType method
• Flattened nested conditional structures
• Improved code readability

jabgui/src/main/java/org/jabref/migrations/CustomEntryTypePreferenceMigration.java


57. jabgui/src/main/java/org/jabref/gui/frame/FrameDndHandler.java Formatting +2/-4

Remove unnecessary else blocks

• Removed unnecessary else blocks in getBibFiles and getGroups methods
• Simplified conditional logic
• Improved code readability

jabgui/src/main/java/org/jabref/gui/frame/FrameDndHandler.java


58. jablib/src/main/java/org/jabref/model/entry/LinkedFile.java Formatting +6/-9

Remove unnecessary else blocks

• Removed unnecessary else blocks in getFileName and findIn methods
• Simplified nested conditional structures
• Improved code readability

jablib/src/main/java/org/jabref/model/entry/LinkedFile.java


59. jabgui/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java Formatting +5/-6

Remove else block and improve formatting

• Removed unnecessary else block in lambda expression
• Improved indentation in stream operations
• Simplified conditional logic

jabgui/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java


60. jabgui/src/main/java/org/jabref/gui/entryeditor/OptionalFieldsTabBase.java Formatting +4/-6

Remove else blocks and improve formatting

• Removed unnecessary else blocks in determineFieldsToShow method
• Improved indentation in method chaining
• Simplified conditional logic

jabgui/src/main/java/org/jabref/gui/entryeditor/OptionalFieldsTabBase.java


61. jabgui/src/main/java/org/jabref/gui/entryeditor/citationrelationtab/BibEntryView.java Formatting +4/-6

Remove unnecessary else blocks

• Removed unnecessary else blocks in createSummary and createLabel methods
• Simplified conditional logic
• Improved code readability

jabgui/src/main/java/org/jabref/gui/entryeditor/citationrelationtab/BibEntryView.java


62. jablib/src/main/java/org/jabref/logic/layout/format/WrapFileLinks.java ✨ Enhancement +5/-7

Remove else block and use isBlank() method

• Removed unnecessary else block in parseFormatString method
• Replaced trim().isEmpty() with isBlank() for cleaner blank checking
• Simplified conditional logic

jablib/src/main/java/org/jabref/logic/layout/format/WrapFileLinks.java


63. jabgui/src/main/java/org/jabref/gui/actions/ActionFactory.java Formatting +8/-9

Remove else block and simplify control flow

• Removed unnecessary else block in getAssociatedNode method
• Simplified conditional logic
• Improved code readability

jabgui/src/main/java/org/jabref/gui/actions/ActionFactory.java


64. jablib/src/main/java/org/jabref/logic/journals/JournalAbbreviationLoader.java Formatting +7/-8

Remove else block and simplify control flow

• Removed unnecessary else block in loadLtwaRepository method
• Flattened nested conditional structures
• Improved code readability

jablib/src/main/java/org/jabref/logic/journals/JournalAbbreviationLoader.java


65. jabgui/src/main/java/org/jabref/gui/exporter/WriteMetadataToLinkedPdfsAction.java Formatting +6/-7

Remove else block and simplify control flow

• Removed unnecessary else block in execute method
• Simplified conditional logic
• Improved code readability

jabgui/src/main/java/org/jabref/gui/exporter/WriteMetadataToLinkedPdfsAction.java


66. jablib/src/main/java/org/jabref/logic/citationstyle/CSLStyleUtils.java Formatting +4/-5

Improve formatting and remove else block

• Improved indentation in switch expression cases
• Removed unnecessary else block in parseStyleInfo method
• Simplified conditional logic

jablib/src/main/java/org/jabref/logic/citationstyle/CSLStyleUtils.java


67. jablib/src/main/java/org/jabref/logic/push/PushToSublimeText.java Formatting +2/-3

Remove else block and improve formatting

• Removed unnecessary else block in getCommandLine method
• Changed array initialization from new String[] {} to new String[]{} for consistency
• Simplified conditional logic

jablib/src/main/java/org/jabref/logic/push/PushToSublimeText.java


68. jabgui/src/main/java/org/jabref/gui/undo/UndoableInsertEntries.java Formatting +7/-11

Remove else blocks and use else if chain

• Removed unnecessary else blocks and converted to else if chain
• Simplified nested conditional structures
• Improved code readability

jabgui/src/main/java/org/jabref/gui/undo/UndoableInsertEntries.java


69. jabgui/src/main/java/org/jabref/gui/undo/UndoableRemoveEntries.java Formatting +7/-11

Remove else blocks and use else if chain

• Removed unnecessary else blocks and converted to else if chain
• Simplified nested conditional structures
• Improved code readability

jabgui/src/main/java/org/jabref/gui/undo/UndoableRemoveEntries.java


70. jablib/src/test/java/org/jabref/logic/importer/fetcher/RfcFetcherTest.java 🧪 Tests +3/-3

Use ValueSource instead of CsvSource for single values

• Changed @CsvSource to @ValueSource for parameterized tests with single string values
• Improved test annotation usage

jablib/src/test/java/org/jabref/logic/importer/fetcher/RfcFetcherTest.java


71. jablib/src/main/java/org/jabref/logic/bst/util/BstWidthCalculator.java Formatting +3/-6

Simplify conditional return statements

• Removed unnecessary else block after early return statement
• Moved return 0; statement outside of conditional block
• Simplified control flow by eliminating redundant else clause

jablib/src/main/java/org/jabref/logic/bst/util/BstWidthCalculator.java


72. jablib/src/main/java/org/jabref/logic/citationkeypattern/CitationKeyGenerator.java ✨ Enhancement +2/-3

Simplify returns and use isBlank method

• Removed else block and moved return statement to top level
• Replaced trim().isEmpty() with isBlank() for cleaner string checking

jablib/src/main/java/org/jabref/logic/citationkeypattern/CitationKeyGenerator.java


73. jablib/src/main/java/org/jabref/logic/formatter/bibtexfields/ConvertMSCCodesFormatter.java Formatting +10/-11

Flatten nested conditional and try-catch blocks

• Removed nested else block and flattened try-catch structure
• Moved try-catch block to top level after early return

jablib/src/main/java/org/jabref/logic/formatter/bibtexfields/ConvertMSCCodesFormatter.java


74. jablib/src/main/java/org/jabref/logic/importer/AuthorListParser.java Formatting +2/-4

Remove redundant else blocks after returns

• Removed multiple unnecessary else blocks after return statements
• Simplified control flow in three separate methods

jablib/src/main/java/org/jabref/logic/importer/AuthorListParser.java


75. jablib/src/main/java/org/jabref/model/util/OptionalUtil.java Formatting +3/-6

Simplify Optional utility method returns

• Removed else blocks in three utility methods
• Simplified conditional returns by moving statements to top level

jablib/src/main/java/org/jabref/model/util/OptionalUtil.java


76. jabgui/src/main/java/org/jabref/gui/help/VersionWorker.java Formatting +5/-7

Flatten nested conditional structure

• Removed else block and flattened nested if statement
• Moved conditional logic to top level after early return

jabgui/src/main/java/org/jabref/gui/help/VersionWorker.java


77. jabgui/src/main/java/org/jabref/gui/entryeditor/DeprecatedFieldsTab.java Formatting +3/-4

Simplify conditional return in field determination

• Removed else block and moved return statement to top level
• Adjusted indentation for method chaining

jabgui/src/main/java/org/jabref/gui/entryeditor/DeprecatedFieldsTab.java


78. jabgui/src/main/java/org/jabref/gui/util/ViewModelTextFieldTableCellVisualizationFactory.java Formatting +8/-9

Flatten nested conditionals in TextField lookup

• Removed else block and flattened nested conditional structure
• Moved subsequent if statements to top level

jabgui/src/main/java/org/jabref/gui/util/ViewModelTextFieldTableCellVisualizationFactory.java


79. jablib/src/main/java/org/jabref/logic/bibtex/comparator/MetaDataDiff.java Formatting +6/-7

Simplify metadata comparison logic

• Removed else block and moved logic to top level
• Simplified control flow in static compare method

jablib/src/main/java/org/jabref/logic/bibtex/comparator/MetaDataDiff.java


80. jabgui/src/main/java/org/jabref/gui/autocompleter/SuggestionProvider.java Formatting +7/-8

Simplify suggestion provider return logic

• Removed else block after stream operation
• Moved return statement to top level

jabgui/src/main/java/org/jabref/gui/autocompleter/SuggestionProvider.java


81. jablib/src/main/java/org/jabref/logic/layout/LayoutHelper.java Formatting +9/-11

Flatten nested conditionals in layout parsing

• Removed multiple else blocks in parseField method
• Flattened nested conditional structures

jablib/src/main/java/org/jabref/logic/layout/LayoutHelper.java


82. jablib/src/main/java/org/jabref/logic/openoffice/action/EditMerge.java ✨ Enhancement +2/-2

Use isBlank and parameterized logging

• Replaced trim().isEmpty() with isBlank() for cleaner string checking
• Updated logger call to use parameterized format string

jablib/src/main/java/org/jabref/logic/openoffice/action/EditMerge.java


83. jablib/src/main/java/org/jabref/logic/ai/ingestion/GenerateEmbeddingsTask.java Formatting +4/-6

Flatten nested conditionals in embeddings generation

• Removed nested else block and flattened conditional structure
• Simplified control flow in file ingestion logic

jablib/src/main/java/org/jabref/logic/ai/ingestion/GenerateEmbeddingsTask.java


84. jabgui/src/main/java/org/jabref/gui/linkedfile/DownloadLinkedFileAction.java Formatting +4/-6

Flatten nested conditionals in SSL handshake check

• Removed multiple else blocks and flattened nested conditionals
• Simplified error handling flow

jabgui/src/main/java/org/jabref/gui/linkedfile/DownloadLinkedFileAction.java


85. jablib/src/main/java/org/jabref/model/openoffice/util/OOResult.java Formatting +3/-6

Simplify OOResult method returns

• Removed else blocks in three methods (map, mapError, asVoidResult)
• Simplified conditional returns

jablib/src/main/java/org/jabref/model/openoffice/util/OOResult.java


86. jabsrv/src/main/java/org/jabref/http/server/cayw/CitationProperties.java ✨ Enhancement +5/-2

Use Predicate.not for cleaner filtering

• Added static import for Predicate.not
• Replaced lambda s -> !s.isEmpty() with not(String::isEmpty) in two methods

jabsrv/src/main/java/org/jabref/http/server/cayw/CitationProperties.java


87. jablib/src/main/java/org/jabref/logic/layout/format/HTMLChars.java Formatting +6/-8

Flatten nested conditional in HTML character formatting

• Removed else block and flattened nested conditional
• Moved if statement to top level

jablib/src/main/java/org/jabref/logic/layout/format/HTMLChars.java


88. jabgui/src/main/java/org/jabref/cli/CliImportHelper.java Formatting +3/-5

Flatten nested conditionals in file import

• Removed nested else block and flattened conditional structure
• Simplified file path handling logic

jabgui/src/main/java/org/jabref/cli/CliImportHelper.java


89. jablib/src/main/java/org/jabref/logic/importer/fileformat/IsiImporter.java ✨ Enhancement +2/-2

Replace trim().isEmpty() with isBlank()

• Replaced trim().isEmpty() with isBlank() in two locations
• Improved string checking consistency

jablib/src/main/java/org/jabref/logic/importer/fileformat/IsiImporter.java


90. jabgui/src/main/java/org/jabref/gui/util/comparator/NumericFieldComparator.java Formatting +7/-10

Flatten nested conditionals in numeric comparison

• Removed nested else blocks and flattened conditional structure
• Simplified comparison logic with multiple else-if statements

jabgui/src/main/java/org/jabref/gui/util/comparator/NumericFieldComparator.java


91. jablib/src/test/java/org/jabref/logic/openoffice/style/OOBibStyleTestHelper.java Formatting +8/-9

Simplify test helper method return logic

• Removed else block and moved logic to top level
• Simplified conditional return in test helper method

jablib/src/test/java/org/jabref/logic/openoffice/style/OOBibStyleTestHelper.java


92. jablib/src/main/java/org/jabref/logic/importer/fileformat/MedlineImporter.java Formatting +5/-7

Flatten nested conditionals in keyword processing

• Removed nested else block and flattened conditional structure
• Simplified keyword handling logic

jablib/src/main/java/org/jabref/logic/importer/fileformat/MedlineImporter.java


93. jabgui/src/main/java/org/jabref/gui/fieldeditors/optioneditors/mapbased/MapBasedEditorViewModel.java Formatting +3/-5

Simplify StringConverter method returns

• Removed else blocks in StringConverter methods
• Simplified toString and fromString method returns

jabgui/src/main/java/org/jabref/gui/fieldeditors/optioneditors/mapbased/MapBasedEditorViewModel.java


94. jablib/src/main/java/org/jabref/model/entry/types/EntryTypeFactory.java Formatting +4/-5

Simplify entry type equality comparison

• Removed else block and moved return statement to top level
• Simplified equality comparison logic

jablib/src/main/java/org/jabref/model/entry/types/EntryTypeFactory.java


95. jabgui/src/main/java/org/jabref/gui/libraryproperties/keypattern/KeyPatternPropertiesViewModel.java ✨ Enhancement +2/-2

Replace trim().isEmpty() with isBlank()

• Replaced trim().isEmpty() with isBlank() in two locations
• Improved string checking consistency

jabgui/src/main/java/org/jabref/gui/libraryproperties/keypattern/KeyPatternPropertiesViewModel.java


96. jabgui/src/main/java/org/jabref/gui/fieldeditors/optioneditors/MonthEditorViewModel.java Formatting +4/-8

Flatten nested conditionals in month editor

• Removed nested else blocks and flattened conditional structure
• Simplified StringConverter method logic

jabgui/src/main/java/org/jabref/gui/fieldeditors/optioneditors/MonthEditorViewModel.java


97. jablib/src/test/java/org/jabref/logic/l10n/LocalizationParser.java Formatting +4/-5

Simplify localization entry finding

• Removed else block and moved logic to top level
• Simplified localization entry finding logic

jablib/src/test/java/org/jabref/logic/l10n/LocalizationParser.java


98. jablib/src/main/java/org/jabref/logic/formatter/Formatters.java Formatting +3/-5

Flatten nested conditionals in formatter selection

• Removed multiple else<...

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (5) 📎 Requirement gaps (0)

Grey Divider


Remediation recommended

1. getLookupResult().get() after isEmpty() 📘 Rule violation ⚙ Maintainability
Description
The updated formatBibliographyEntryBody uses citedKey.getLookupResult().isEmpty() and then calls
citedKey.getLookupResult().get() multiple times. This violates the requirement to use idiomatic
Optional control flow and increases the risk of future unsafe refactors.
Code

jablib/src/main/java/org/jabref/logic/openoffice/style/OOFormatBibliography.java[R91-98]

+        // Resolved entry, use the layout engine
+        BibEntry bibentry = citedKey.getLookupResult().get().entry;
+        Layout layout = style.getReferenceFormat(bibentry.getType());
+        layout.setPostFormatter(POSTFORMATTER);
+
+        return formatFullReferenceOfBibEntry(layout,
+                bibentry,
+                citedKey.getLookupResult().get().database,
Evidence
PR Compliance ID 40 forbids Optional.isEmpty()/isPresent() checks followed by Optional.get()
in new/modified code. The PR adds code that checks isEmpty() and then dereferences the Optional
via get() when building the resolved bibliography entry.

jablib/src/main/java/org/jabref/logic/openoffice/style/OOFormatBibliography.java[91-99]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`formatBibliographyEntryBody` checks `citedKey.getLookupResult().isEmpty()` and then repeatedly calls `citedKey.getLookupResult().get()`, which violates the Optional-control-flow guideline.
## Issue Context
This code path formats bibliography entries; the Optional should be unwrapped once using idiomatic methods (e.g., `orElseThrow`) or mapped/handled via `map`/`orElseGet`.
## Fix Focus Areas
- jablib/src/main/java/org/jabref/logic/openoffice/style/OOFormatBibliography.java[86-100]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. orElse(null) passed as argument 📘 Rule violation ≡ Correctness
Description
The PR adds a call that passes null via citedKey.getUniqueLetter().orElse(null) into
formatFullReferenceOfBibEntry. This keeps a non-explicit null contract and undermines the
null-safety requirement to avoid passing null and/or to express nullability with JSpecify/Optional.
Code

jablib/src/main/java/org/jabref/logic/openoffice/style/OOFormatBibliography.java[R96-99]

+        return formatFullReferenceOfBibEntry(layout,
+                bibentry,
+                citedKey.getLookupResult().get().database,
+                citedKey.getUniqueLetter().orElse(null));
Evidence
PR Compliance ID 15 disallows passing null as an argument unless explicitly modeled and requires
making nullability explicit (e.g., via Optional/JSpecify annotations). The PR adds a call site that
passes null using orElse(null) for the uniquefier parameter.

AGENTS.md
jablib/src/main/java/org/jabref/logic/openoffice/style/OOFormatBibliography.java[96-99]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
New/modified code passes `null` via `citedKey.getUniqueLetter().orElse(null)` into `formatFullReferenceOfBibEntry`, creating a non-explicit null contract.
## Issue Context
The method currently accepts a plain `String` parameter and uses `null` as a sentinel. Prefer representing the absence explicitly (e.g., `Optional<String>` parameter) or adding explicit JSpecify nullness annotations and avoiding null where possible.
## Fix Focus Areas
- jablib/src/main/java/org/jabref/logic/openoffice/style/OOFormatBibliography.java[96-122]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. parsedDate.get() in switch 📘 Rule violation ⚙ Maintainability
Description
The modified date-extraction switch calls parsedDate.get() multiple times after
parsedDate.isPresent(). This violates the Optional control-flow rule and makes the code harder to
refactor safely.
Code

jablib/src/main/java/org/jabref/model/entry/BibEntry.java[R512-516]

+                        parsedDate.get().getYear().map(Object::toString);
       case StandardField.MONTH ->
-                            parsedDate.get().getMonth().map(Month::getJabRefFormat);
+                        parsedDate.get().getMonth().map(Month::getJabRefFormat);
       case StandardField.DAY ->
-                            parsedDate.get().getDay().map(Object::toString);
+                        parsedDate.get().getDay().map(Object::toString);
Evidence
PR Compliance ID 40 requires avoiding isPresent()/isEmpty() followed by get() in new/modified
code. The touched switch branches repeatedly dereference parsedDate using parsedDate.get() after
presence was checked.

jablib/src/main/java/org/jabref/model/entry/BibEntry.java[509-523]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`genericGetFieldOrAlias` uses `parsedDate.isPresent()` and then repeatedly calls `parsedDate.get()` inside a `switch`, which is non-idiomatic Optional usage.
## Issue Context
The logic can be expressed by switching on `field` and returning `parsedDate.flatMap(...)` for each case (or by unwrapping once with `orElseThrow()` in a way that avoids `isPresent()`/`get()` patterns).
## Fix Focus Areas
- jablib/src/main/java/org/jabref/model/entry/BibEntry.java[509-523]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (2)
4. Throw IllegalStateException in switch 📘 Rule violation ☼ Reliability
Description
The modified switch default throws new IllegalStateException("Unexpected value"), which violates
the guideline to avoid throwing unchecked exceptions in normal logic paths. This can lead to hard
failures instead of graceful handling if unexpected fields reach this code path.
Code

jablib/src/main/java/org/jabref/model/entry/BibEntry.java[R517-518]

       default ->
-                            throw new IllegalStateException("Unexpected value");
+                        throw new IllegalStateException("Unexpected value");
Evidence
PR Compliance ID 12 forbids throwing unchecked exceptions like IllegalStateException in
new/modified code. The PR touches the default switch branch that throws IllegalStateException.

AGENTS.md
jablib/src/main/java/org/jabref/model/entry/BibEntry.java[517-519]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The default branch in the date-field switch throws `IllegalStateException("Unexpected value")`, which is disallowed by the exception-handling compliance rule.
## Issue Context
If the intent is “unreachable”, consider a non-throwing fallback (e.g., `Optional.empty()`), or restructure the logic to ensure only YEAR/MONTH/DAY reach the switch without relying on unchecked exceptions.
## Fix Focus Areas
- jablib/src/main/java/org/jabref/model/entry/BibEntry.java[509-523]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. lastLine.matches uses String.matches 📘 Rule violation ➹ Performance
Description
isStartOfWorkingPaper uses String.matches(...), which recompiles the regex each time and is
called repeatedly during parsing. This violates the compiled-regex requirement and can degrade
performance in large imports.
Code

jablib/src/main/java/org/jabref/logic/importer/fileformat/RepecNepImporter.java[358]

+        return this.lastLine.matches("\\d+\\.\\s.*") && !this.inOverviewSection && this.preLine.isBlank();
Evidence
PR Compliance ID 10 requires using compiled Pattern constants instead of repeated
String.matches(...). The PR modifies a line that still uses
this.lastLine.matches("\\d+\\.\\s.*") inside a parser helper that is used while reading lines.

AGENTS.md
jablib/src/main/java/org/jabref/logic/importer/fileformat/RepecNepImporter.java[355-359]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`isStartOfWorkingPaper` uses `String.matches("\\d+\\.\\s.*")`, which recompiles the regex on every call.
## Issue Context
This method is used during import parsing and may be invoked many times; it should use a `private static final Pattern` and `PATTERN.matcher(lastLine).matches()`.
## Fix Focus Areas
- jablib/src/main/java/org/jabref/logic/importer/fileformat/RepecNepImporter.java[226-235]
- jablib/src/main/java/org/jabref/logic/importer/fileformat/RepecNepImporter.java[355-359]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label May 3, 2026
@koppor

koppor commented May 3, 2026

Copy link
Copy Markdown
Member

Does IntelliJ start fighting with OpenRewrite again?

--- a/jablib/src/test/java/org/jabref/logic/openoffice/style/OOBibStyleTestHelper.java
+++ b/jablib/src/test/java/org/jabref/logic/openoffice/style/OOBibStyleTestHelper.java
@@ -101,11 +101,11 @@ class OOBibStyleTestHelper {
         }
         List<CitationMarkerNumericEntry> input =
                 num.stream()
-                        .map(n ->
-                                new CitationMarkerNumericEntryImpl("key" + n,
-                                        n,
-                                        Optional.empty()))
-                        .collect(Collectors.toList());
+                   .map(n ->
+                           new CitationMarkerNumericEntryImpl("key" + n,
+                                   n,
+                                   Optional.empty()))
+                   .collect(Collectors.toList());
         return style.getNumCitationMarker2(input, minGroupingCount).toString();
     }

@github-actions github-actions Bot added status: no-bot-comments status: changes-required Pull requests that are not yet complete and removed status: changes-required Pull requests that are not yet complete status: no-bot-comments labels May 3, 2026
@koppor

koppor commented May 3, 2026

Copy link
Copy Markdown
Member

@timtebeek was so nice to investigate parsing failures - openrewrite/rewrite#7554 (comment) - thank you, Tim!

Oliver Kopp and others added 2 commits May 4, 2026 03:21
@koppor

koppor commented May 4, 2026

Copy link
Copy Markdown
Member

Does IntelliJ start fighting with OpenRewrite again?

I added a reformatting step after OpenRewriteCall. Should mitigate.

@koppor koppor enabled auto-merge May 4, 2026 01:49
@InAnYan

InAnYan commented May 4, 2026

Copy link
Copy Markdown
Member Author

Ufff. I have once fixed tests and check style after open rewrite. But I haven’t imagine it’s that much work 😅

Comment on lines +47 to +50
} else if (OS.WINDOWS) {
file = Path.of(address);
} else {
if (OS.WINDOWS) {
file = Path.of(address);
} else {
file = Path.of(address.replace("~", System.getProperty("user.home")));
}
file = Path.of(address.replace("~", System.getProperty("user.home")));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks suspicious to me

Comment on lines +140 to 147
} else // When currentUserMessageScroll is set to NEW_NON_EXISTENT_MESSAGE, then we should:
// 1) either clear the prompt, if user scrolls down the most recent history entry.
// 2) do nothing, if user starts to edit the history entry.
// We distinguish these two cases by checking showingHistoryMessage, which is true for -1 message, and false for others.
if (showingHistoryMessage.get()) {
userPromptTextArea.setText("");
}
}
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically correct, but stylistically a wtf.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} else {
// There was no specific editor found
}
// There was no specific editor found

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment looks displaced now. Needs more flesh

Comment on lines 176 to +179
if (parentNode == null) {
return null;
} else {
return parentNode.getGroup();
}
return parentNode.getGroup();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Early return pattern is taken too far here. Was better readable and understandable before. Maybe we have to reconfigure the recipies.

Comment on lines 280 to +291
if (sidePane.getChildren().isEmpty()) {
if (horizontalDividerSubscription != null) {
horizontalDividerSubscription.unsubscribe();
}
horizontalSplit.getItems().remove(sidePane);
} else {
if (!horizontalSplit.getItems().contains(sidePane)) {
horizontalSplit.setVisible(false);
horizontalSplit.getItems().addFirst(sidePane);
Platform.runLater(() -> {
updateHorizontalDividerPosition();
horizontalSplit.setVisible(true);
});
}
} else if (!horizontalSplit.getItems().contains(sidePane)) {
horizontalSplit.setVisible(false);
horizontalSplit.getItems().addFirst(sidePane);
Platform.runLater(() -> {
updateHorizontalDividerPosition();
horizontalSplit.setVisible(true);
});

@calixtus calixtus May 4, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are two very different categories here. else if suggest they are on the same level. This is going too far.

Comment on lines -54 to -63
} else {
return Optional.of(suffix); // return the first one we found, anyway.
}
} else {
// Check if there are path separators in the suffix - if so, it is definitely
return Optional.of(suffix); // return the first one we found, anyway.
} else // Check if there are path separators in the suffix - if so, it is definitely
// not a proper suffix, so we should give up:
if (link.substring(index + 1).indexOf('/') >= 1) {
return Optional.empty();
} else {
return Optional.of(link.substring(index + 1));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to far.

Comment on lines 165 to 173
if (StringUtil.isBlank(linkedFile.getDescription())) {
return ControlHelper.truncateString(linkedFile.getLink(), -1, "...",
ControlHelper.EllipsisPosition.CENTER);
} else {
return ControlHelper.truncateString(linkedFile.getDescription(), -1, "...",
ControlHelper.EllipsisPosition.CENTER) + " (" +
ControlHelper.truncateString(linkedFile.getLink(), -1, "...",
ControlHelper.EllipsisPosition.CENTER) + ")";
}
return ControlHelper.truncateString(linkedFile.getDescription(), -1, "...",
ControlHelper.EllipsisPosition.CENTER) + " (" +
ControlHelper.truncateString(linkedFile.getLink(), -1, "...",
ControlHelper.EllipsisPosition.CENTER) + ")";
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should represent some switch like behaviour. Now looks like early return pattern. Going too far.

Comment on lines 30 to +35
if (object == null) {
return null;
} else {
if (databaseMode == BibDatabaseMode.BIBLATEX) {
return String.valueOf(object.getNumber());
} else {
return object.getJabRefFormat();
}
} else if (databaseMode == BibDatabaseMode.BIBLATEX) {
return String.valueOf(object.getNumber());
}
return object.getJabRefFormat();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going too far

Comment on lines 38 to +41
if (StringUtil.isNotBlank(string)) {
return Langid.parse(string).orElse(null);
} else {
return null;
}
return null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not early return pattern. Going to far.

Comment on lines 96 to +99
if ("text/html".equalsIgnoreCase(mimeType)) {
return Optional.of(HTML_FALLBACK_TYPE);
} else {
return Optional.empty();
}
return Optional.empty();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not early return pattern. Going to far.

Comment on lines 30 to +33
if (Files.isDirectory(pathname)) {
return true;
} else {
return fileFilter.accept(pathname) && !lookup.lookupDatabase(pathname) && !lookup.getPathOfDatabase().equals(pathname);
}
return fileFilter.accept(pathname) && !lookup.lookupDatabase(pathname) && !lookup.getPathOfDatabase().equals(pathname);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not early return pattern. Going to far.

return Stream.of(linkedFile);
}
return Stream.of(linkedFile);
}).toList();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not early return pattern. Going to far.

Comment on lines 100 to +111
if (so.getOrderType() == SaveOrder.OrderType.TABLE) {
// We need to "flatten out" SaveOrder.OrderType.TABLE as BibWriter does not have access to preferences
List<TableColumn<BibEntryTableViewModel, ?>> sortOrder = libraryTab.getMainTable().getSortOrder();
return new SelfContainedSaveOrder(
SaveOrder.OrderType.SPECIFIED,
sortOrder.stream()
.filter(col -> col instanceof MainTableColumn<?>)
.map(column -> ((MainTableColumn<?>) column).getModel())
.flatMap(model -> model.getSortCriteria().stream())
.toList());
} else {
return SelfContainedSaveOrder.of(so);
}
return SelfContainedSaveOrder.of(so);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not early return pattern. Going to far.

Comment on lines 299 to +310
if (parserResult.hasWarnings()) {
LOGGER.warn("Could not store entry: {}", parserResult.warnings());
String errors = parserResult.getErrorMessage();
dialogService.showErrorDialogAndWait(errors);
validationMessage.setValue(ValidationMessage.error(Localization.lang("Failed to parse Bib(La)TeX: %0", errors)));
return;
} else {
LOGGER.warn("No entries found.");
String errors = Localization.lang("No entries available");
dialogService.showErrorDialogAndWait(errors);
validationMessage.setValue(ValidationMessage.error(Localization.lang("Failed to parse Bib(La)TeX: %0", errors)));
return;
}
LOGGER.warn("No entries found.");
String errors = Localization.lang("No entries available");
dialogService.showErrorDialogAndWait(errors);
validationMessage.setValue(ValidationMessage.error(Localization.lang("Failed to parse Bib(La)TeX: %0", errors)));
return;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not early return pattern. Going to far.

@calixtus calixtus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stopped reviewing. The rewrite recipies are too comprehensive.

Early return pattern is applicated too harshly, often obfuscating and disfiguring deliberately chosen parallelisms in code style.

Merging this in the current state would vastly reduce code readability and code quality.

@calixtus calixtus marked this pull request as draft May 4, 2026 08:40
auto-merge was automatically disabled May 4, 2026 08:40

Pull request was converted to draft

@github-actions github-actions Bot added status: changes-required Pull requests that are not yet complete and removed status: no-bot-comments labels May 4, 2026
@InAnYan

InAnYan commented May 4, 2026

Copy link
Copy Markdown
Member Author

Okay, then probably better to turn that recipe off and then view the PR. Maybe I’ll do it today’s evening on/after the call

@InAnYan InAnYan closed this May 4, 2026
@calixtus

calixtus commented May 4, 2026

Copy link
Copy Markdown
Member

Thanks. I'm thinking about how to distinguish real early return cases from switch like if statements, but I'm not sure if this is possible at all to configure in rewrite.

@calixtus

calixtus commented May 4, 2026

Copy link
Copy Markdown
Member

Not to be misunderstood, reactivation and implementation of rewrite changes are necessary, yet the early return rule seems to strong.

@timtebeek

timtebeek commented May 4, 2026

Copy link
Copy Markdown

Perhaps it helps to convert the switch-like if statements to an actual switch before unwrapping the last else:
https://docs.openrewrite.org/recipes/java/migrate/lang/ifelseifconstructtoswitch

@calixtus

calixtus commented May 4, 2026

Copy link
Copy Markdown
Member

In theory yes, depends maybe on the complexity of the constraints. Please open an issue.

@koppor

koppor commented May 4, 2026

Copy link
Copy Markdown
Member

Perhaps it helps to convert the switch-like if statements to an actual switch before unwrapping the last else: https://docs.openrewrite.org/recipes/java/migrate/lang/ifelseifconstructtoswitch

Thank you for the hint. This seems to be a manual checking process.


The if handling itself is nice - it covers our "fail fast" principle. But I agree that not 100% of the cases are covered.

I really wonder how this came in - but maybe, because our check worfklow did not work properly.

} else {
return ManageKeywordsDisplayType.CONTAINED_IN_ALL_ENTRIES;
}
return ManageKeywordsDisplayType.CONTAINED_IN_ALL_ENTRIES;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this is strange to read -- maybe, because the fail-fast length is equal to the other length?

@koppor koppor mentioned this pull request May 4, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: changes-required Pull requests that are not yet complete

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants