-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
base: main
Are you sure you want to change the base?
Conversation
Recording.2025-02-13.mp4There 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. |
Recording.2025-02-13.mp4 |
There was a problem hiding this 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.
Please review |
I have refactored the code a lot and used better practices. |
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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.
Recording.2025-02-20.mp4The feature is completed. |
src/main/java/org/jabref/gui/integrity/IntegrityCheckDialogViewModel.java
Show resolved
Hide resolved
src/main/java/org/jabref/gui/integrity/IntegrityCheckDialog.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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".
@priyanshu16095 Would be nice if the code style comment were addressed. Red tests prevent reviewers from looking into 😇 |
There was a problem hiding this 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
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")), |
There was a problem hiding this comment.
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.
org.jabref.logic.integrity.IntegrityMessage
should containIntegrityIssue
. Otherwise it is too decoupled- 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.
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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.
This reverts commit 102e789.
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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.
Apologies for the clutter every time a new check fails. |
Fixes #11419
This PR introduces a functionality to fix integrity issues either individually or all at once by selecting a type.
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)