Skip to content
New issue

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

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

Already on GitHub? # to your account

Add fix options for integrity issues #12495

Open
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

priyanshu16095
Copy link
Contributor

@priyanshu16095 priyanshu16095 commented Feb 12, 2025

Fixes #11419

This PR introduces a functionality to fix integrity issues either individually or all at once by selecting a type.

Mandatory checks

  • I own the copyright of the code submitted and I licence 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 (for UI changes)
  • 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.

Screenshot (121)
Screenshot (122)

@priyanshu16095
Copy link
Contributor Author

Recording.2025-02-13.mp4

There is a problem with selecting messages using the Shift key. One has to click on a message first, as the focus moves to the entry editor. However, when clicking again with the mouse, all the selected entries are lost.

@priyanshu16095
Copy link
Contributor Author

priyanshu16095 commented Feb 12, 2025

Recording.2025-02-13.mp4

github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

JUnit tests are failing. In the area "Some checks were not successful", locate "Tests / Unit tests (pull_request)" and click on "Details". This brings you to the test output.

You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide.

@priyanshu16095
Copy link
Contributor Author

Please review

@priyanshu16095
Copy link
Contributor Author

I have refactored the code a lot and used better practices.
I have used an enum as, without it I would have to use switch-case in every method.
Please guide me on whether I am moving in the right direction.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

JUnit tests are failing. In the area "Some checks were not successful", locate "Tests / Unit tests (pull_request)" and click on "Details". This brings you to the test output.
You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

JUnit tests are failing. In the area "Some checks were not successful", locate "Tests / Unit tests (pull_request)" and click on "Details". This brings you to the test output.
You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

JUnit tests are failing. In the area "Some checks were not successful", locate "Tests / Unit tests (pull_request)" and click on "Details". This brings you to the test output.
You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide.

@priyanshu16095
Copy link
Contributor Author

Recording.2025-02-20.mp4

The feature is completed.
The fixes for the issue are left to be added.

@koppor koppor added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Feb 23, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Your code currently does not meet JabRef's code guidelines. We use OpenRewrite to ensure "modern" Java coding practices. The issues found can be automatically fixed. Please execute the gradle task rewriteRun, check the results, commit, and push.
You can check the detailed error output by navigating to your pull request, selecting the tab "Checks", section "Tests" (on the left), subsection "OpenRewrite".

@koppor koppor added status: waiting-for-feedback The submitter or other users need to provide more information about the issue and removed status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers status: waiting-for-feedback The submitter or other users need to provide more information about the issue labels Feb 25, 2025
@koppor koppor requested a review from calixtus February 25, 2025 15:10
@koppor
Copy link
Member

koppor commented Feb 26, 2025

@priyanshu16095 Would be nice if the code style comment were addressed. Red tests prevent reviewers from looking into 😇

Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

I have some general architecture remark (see inside)

While checking, I found that not all checkers are handled. E.g., org.jabref.logic.integrity.HTMLCharacterChecker

Each checker needs to specify how its issue can be fixed.

For HTML, it is

  • bibtex mode: convert to latex
  • biblatex mode: convert to unicode

image


Maybe, you can come up with some data strucutre how this can be specified (as object for each integrity issue entry in the enum?) and then we can try to fill it -- you can submit code with null or non-compiling


public enum IntegrityIssue {
CITATION_KEY_DEVIATES_FROM_GENERATED_KEY(InternalField.KEY_FIELD, Localization.lang("Citation key deviates from generated key")),
BIBTEX_FIELD_ONLY_KEY(InternalField.KEY_FIELD, Localization.lang("bibtex field only"), Localization.lang("Remove field")),
Copy link
Member

Choose a reason for hiding this comment

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

I checked this. The fix is the "bibtex-to-biblatex" transformation in the cleanup dialog.

I like the idea of a IntegrityIssue object.

For a good maintainable solution

Outline. Maybe, you can refine it. If you need help, I can think more.

  1. org.jabref.logic.integrity.IntegrityMessage should contain IntegrityIssue. Otherwise it is too decoupled
  2. Instead of a string for the fix, there maybe should be a callable which can be called from the ui

JavaDoc or general documentation (Markdown in docs/code-howtos) should be done, because the code is not straight-forward.

Copy link
Contributor Author

@priyanshu16095 priyanshu16095 Feb 28, 2025

Choose a reason for hiding this comment

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

Regarding decoupling issue:

Initially, to implement this roughly, I have to use switch-cases in each method, to overcome this problem, I thought of using an enum to organize things better.

The bad thing is that the enum identifies the issue based on the string message, such as "Citation key deviates from generated key", if this message differs between the IntegrityIssue enum and the IntegrityMessage record, it will not be shown as a fix.

new IntegrityMessage(Localization.lang("Citation key deviates from generated key"), entry, InternalField.KEY_FIELD));

CITATION_KEY_DEVIATES_FROM_GENERATED_KEY(InternalField.KEY_FIELD, Localization.lang("Citation key deviates from generated key"))

Another thing I attempted to solve this was replacing the following code:

results.add(new IntegrityMessage(Localization.lang("odd number of unescaped '#'"), entry, field.getKey()));

with

results.add(new IntegrityMessage(IntegrityIssue.ODD_NUMBER_OF_UNESCAPED.getText(), entry, field.getKey()));

However, this change failed the respectLayeredArchitecture() check, so I reverted it and decided to wait for a review.
But now works fine as i have moved the enum to logic directory.

Guide me if am wrong, the problem of decoupling is solved by this as the message to IntegrityMessage is passed by using IntegrityIssue

results.add(new IntegrityMessage(IntegrityIssue.ODD_NUMBER_OF_UNESCAPED.getText(), entry, field.getKey()));

(If this is approved, test files also need to be changed.)

Copy link
Contributor Author

@priyanshu16095 priyanshu16095 Feb 28, 2025

Choose a reason for hiding this comment

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

All the checkers have been added (almost), and tried to make the architecture more simpler.

Copy link
Contributor Author

@priyanshu16095 priyanshu16095 Feb 28, 2025

Choose a reason for hiding this comment

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

The IntegrityIssue enum can be modified to handle multiple fixes for a single issue.
However, to keep it simple for now, I have limited it to just one fix.
Based on my knowledge, for BIBTEX_FIELD_ONLY_KEY issue I thought the appropriate fix was to remove the field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot (178)

Works fine!

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Your code currently does not meet JabRef's code guidelines. We use Checkstyle to identify issues. Please carefully follow the setup guide for the codestyle. Afterwards, please run checkstyle locally and fix the issues.
In case of issues with the import order, double check that you activated Auto Import. You can trigger fixing imports by pressing Ctrl+Alt+O to trigger Optimize Imports.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Your code currently does not meet JabRef's code guidelines. We use Checkstyle to identify issues. Please carefully follow the setup guide for the codestyle. Afterwards, please run checkstyle locally and fix the issues.
In case of issues with the import order, double check that you activated Auto Import. You can trigger fixing imports by pressing Ctrl+Alt+O to trigger Optimize Imports.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

JUnit tests are failing. In the area "Some checks were not successful", locate "Tests / Unit tests (pull_request)" and click on "Details". This brings you to the test output.
You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Your code currently does not meet JabRef's code guidelines. We use Checkstyle to identify issues. Please carefully follow the setup guide for the codestyle. Afterwards, please run checkstyle locally and fix the issues.
In case of issues with the import order, double check that you activated Auto Import. You can trigger fixing imports by pressing Ctrl+Alt+O to trigger Optimize Imports.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

JUnit tests are failing. In the area "Some checks were not successful", locate "Tests / Unit tests (pull_request)" and click on "Details". This brings you to the test output.
You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

JUnit tests are failing. In the area "Some checks were not successful", locate "Tests / Unit tests (pull_request)" and click on "Details". This brings you to the test output.
You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide.

@priyanshu16095
Copy link
Contributor Author

Apologies for the clutter every time a new check fails.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

integrity check and follow up actions
3 participants