Skip to content

Simplify BibDatabaseWriter by removing unnecessary subclass #13408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 30, 2025

Conversation

HoussemNasri
Copy link
Member

@HoussemNasri HoussemNasri commented Jun 29, 2025

The subclass created an unnecessary abstraction which made it harder to read the code since I had to switch back and forth between the parent and child classes. This could have been a reasonable tradeoff if we had multiple implementations of BibDatabaseWriter but we don't. Also, I don't think it makes sense anymore to have multiple implementations since we have Exporters org.jabref.logic.exporter.Exporter.

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • Change in CHANGELOG.md described in a way that is understandable for the average user (if change is visible to the user)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (if change is visible to the user)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

protected void writeString(BibtexString bibtexString, int maxKeyLength) throws IOException {
// If the string has not been modified, write it back as it was
if (!saveConfiguration.shouldReformatFile() && !bibtexString.hasChanged()) {
LOGGER.debug("Writing parsed serialization {}.", bibtexString.getParsedSerialization());
Copy link

Choose a reason for hiding this comment

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

Debug logging statement provides no additional value beyond what's obvious from the code. This violates the principle that comments/logs should add new information.

Comment on lines +380 to +381
// Write user comments
String userComments = bibtexString.getUserComments();
Copy link

Choose a reason for hiding this comment

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

Comment merely restates what the code does without providing additional context or reasoning. This type of trivial comment should be removed.

Comment on lines +258 to +259
// Writes the file encoding information.
bibWriter.write("% ");
Copy link

Choose a reason for hiding this comment

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

Comment is redundant and simply restates what the code does. It doesn't provide any additional information or reasoning about why this is necessary.

koppor
koppor previously approved these changes Jun 30, 2025
@koppor
Copy link
Member

koppor commented Jun 30, 2025

I went through the diff using RefactoringMinor: Looked good.

Just the checkstyle thing and instantitation in JabKitLauncher to fix.

@koppor koppor added the dev: no-bot-comments If set, there should be no comments from our bots label Jun 30, 2025
@JabRef JabRef deleted a comment from jabref-machine Jun 30, 2025
@HoussemNasri
Copy link
Member Author

JBang is wrong on this one, code compiles fine, it looks like an incremental compilation issue on their side.

@koppor
Copy link
Member

koppor commented Jun 30, 2025

JBang is wrong on this one, code compiles fine, it looks like an incremental compilation issue on their side.

Oh, the test checked out cd1c95a - which is not listed at https://github.com/JabRef/jabref/pull/13408/commits.

The reason is

//DEPS org.jabref:jablib:6.+

The jar on maven central is not udpated - and there the "old" Writer is available.

(In JabRef we accept breaking changes in SNAPSHOTS - and presumbly also accross versions; thus no worries ^^)

@koppor koppor enabled auto-merge June 30, 2025 14:00
@koppor koppor added this pull request to the merge queue Jun 30, 2025
Merged via the queue into JabRef:main with commit 3b06b8b Jun 30, 2025
47 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev: architecture dev: code-quality Issues related to code or architecture decisions dev: no-bot-comments If set, there should be no comments from our bots
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants