Skip to content

Conversation

@Hrishi-Baskaran
Copy link

@Hrishi-Baskaran Hrishi-Baskaran commented Nov 8, 2025

Closes #13794

The current implementation of BibliographyConsistencyCheck.check is only aware of standard entry types of both BibTex and BibLaTex. The current implementation is not able to handle scenarios where the user defines a custom bibliography entry type. In this PR, BibliographyConsistencyCheck.check will be modified to handle consistency checks involving custom entry types in addition to new unit tests to cover the check for a variety of mocked custom entry types.

In my current progress, I have just modified the method signature of the check to include a BibEntryTypesManager object as a parameter. I've modified the code of the check to use this object to gather type definitions - which includes any custom definitions the user added to a manager object. I have also modified test cases in BibliographyConsistencyCheckTest to mock BibEntryTypesManager. So far, in my mocks, I have not added custom entry types to the manager when testing nor have I added new test cases.

Next I plan to add specific unit tests that cover managers with different entry types. I also need to figure a way to dependency inject the application's BibEntryTypesManager when the check is called by a user action and not by a unit test with a mock BibEntryTypesManager.

Steps to test

One can test this feature by running the tests in
BibliographyConsistencyCheckTest

Mandatory checks

@github-actions
Copy link
Contributor

github-actions bot commented Nov 8, 2025

Hey @Hrishi-Baskaran!

Thank you for contributing to JabRef! Your help is truly appreciated ❤️.

We have automatic checks in place, based on which you will soon get automated feedback if any of them are failing. We also use TragBot with custom rules that scans your changes and provides some preliminary comments, before a maintainer takes a look. TragBot is still learning, and may not always be accurate. In the "Files changed" tab, you can go through its comments and just click on "Resolve conversation" if you are sure that it is incorrect, or comment on the conversation if you are doubtful.

Please re-check our contribution guide in case of any other doubts related to our contribution workflow.

@Siedlerchr
Copy link
Member

Please ensure the automatic check are green, otherwise no human will review it

@Hrishi-Baskaran
Copy link
Author

Please ensure the automatic check are green, otherwise no human will review it

Thanks for telling me about this. I will update this on Friday.

@Hrishi-Baskaran Hrishi-Baskaran force-pushed the support-customized-entry-types-consistency-check-13794 branch from e5a97e0 to e12bf76 Compare November 15, 2025 01:36
Also modifies BibliographyConsistencyCheckTest to mock BibEntryTypes
manager.
@Hrishi-Baskaran Hrishi-Baskaran force-pushed the support-customized-entry-types-consistency-check-13794 branch from e12bf76 to ba9446d Compare November 15, 2025 01:57
private final GuiPreferences preferences;
private final BibEntryTypesManager entryTypesManager;
private final UiTaskExecutor taskExecutor;
@Inject private BibEntryTypesManager bibEntryTypesManager;
Copy link
Member

Choose a reason for hiding this comment

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

We don't inject - we pass by constructor


BibliographyConsistencyCheck consistencyCheck = new BibliographyConsistencyCheck();
BibliographyConsistencyCheck.Result result = consistencyCheck.check(databaseContext, (count, total) -> {
BibliographyConsistencyCheck.Result result = consistencyCheck.check(databaseContext, new BibEntryTypesManager(), (count, total) -> {
Copy link
Member

Choose a reason for hiding this comment

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

Refactor this as variable to follow the style of Jabef

// collects fields existing in any entry, scoped by entry type
Map<EntryType, Set<Field>> entryTypeToFieldsInAnyEntryMap = new HashMap<>();
// collects fields existing in all entries, scoped by entry type
// collects fields existing in all entries, scoped by entry typed
Copy link
Member

Choose a reason for hiding this comment

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

Typo - please undo


BibDatabaseContext bibContext = new BibDatabaseContext(database);
BibliographyConsistencyCheck.Result result = new BibliographyConsistencyCheck().check(bibContext, (count, total) -> {
BibliographyConsistencyCheck.Result result = new BibliographyConsistencyCheck().check(bibContext, new BibEntryTypesManager(), (count, total) -> {
Copy link
Member

Choose a reason for hiding this comment

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

Make this a variable in the test - and reuse it.


@BeforeEach
void setUp() {
// TODO: add some custom entry types for this manager and test with it
Copy link
Member

Choose a reason for hiding this comment

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

Yes, please :) - The issue description at #13794 should provide you with one.

@koppor koppor added the status: changes-required Pull requests that are not yet complete label Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support customized entry types in BibliographyConsistencyCheck

3 participants