Skip to content
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

Add fix options for integrity issues #12495

Draft
wants to merge 62 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.

@priyanshu16095 priyanshu16095 marked this pull request as ready for review March 17, 2025 17:33
@koppor
Copy link
Member

koppor commented Mar 19, 2025

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.

The issue seems to be too hard.

No use of formatters at package org.jabref.logic.formatter.bibtexfields, but some hard-coded fixes.

Will takle longer to get this right.

}
}

public void maskTitle(IntegrityMessage message) {
Copy link
Member

Choose a reason for hiding this comment

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

This code seems like AI generated.

I think, I pointed you to org.jabref.logic.cleanup.CleanupJob / org.jabref.logic.cleanup.Formatter

Maybe, we should start on working on a single integrity issue - discuss the archtiecture and then do a second one.

For pages the formatter to use is org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure why it feels AI-generated, it is basic string manipulation, as described in the issue.
Sure, I will use the describe classes.

Copy link
Member

Choose a reason for hiding this comment

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

Following puzzled me very much

updateField(message, StandardField.PAGES, "1-10");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please tell me about the confusion, I am not clear about it.
I created this method because this code was being used in every method for updating fields.

Why I created this method?
Capital letters are not masked using curly brackets {} --> Basic string manipulation as mentioned in the issue, so to update the field I found this way
Map<Field, String> fields = new HashMap<>();
fields.put(field, newValue);
message.entry().setField(fields);
Then to impove the code reusablity, I created the method updateField.

From next time I will ask rather then pushing based on assumptions.

Copy link
Member

Choose a reason for hiding this comment

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

Very OK to push - we can then read code. This is much more easy.

I think, this task is really large. (note the "size: big" label).

Thus, it takes time. Will be a back and forth.


The clenaup jobs should do the cleaning, not manually. Look into how the cleanup dialog works.

(I currently cannot do deeper hints. I can try to draft the architecture next week if we cannot manage to move forward efficiently here)

@koppor
Copy link
Member

koppor commented Mar 19, 2025

It lists all the messages that are present in the table. I will improve this. I will identify issues that cannot be fixed automatically and remove them from the dropdown or AI can be used to fix these.

No need to add AI. Just use existing cleanup actions (see docs.jabref.org/finding-sorting-and-cleaning-entries/saveactions for a list)

Note that I linked the actions in the screenshot at #12495 (review) - and I hoped, you could find the code starting from that 😅

@priyanshu16095
Copy link
Contributor Author

priyanshu16095 commented Mar 20, 2025

In some of methods like formatPageNumberRange, replaceNonASCIICharacters, ensureValidEdition, as well as writing tests for them, I have used AI due to lack of understanding about the fields, I should rather ask or search on the web.

I have planned to ask for improvements about the fixes, which is why I have created fixes for only some issues to limit the usage of AI.

Everything else was planned by me, it took me so much iterations from using switch-case in every method to make use of enum, then solving decoupling issues. I used AI just for writing fix methods due to lack of knowledge.

@subhramit
Copy link
Member

subhramit commented Mar 20, 2025

In some of methods like formatPageNumberRange, replaceNonASCIICharacters, ensureValidEdition, as well as writing tests for them, I have used AI due to lack of understanding about the fields, I should rather ask or search on the web.

I have planned to ask for improvements about the fixes, which is why I have created fixes for only some issues to limit the usage of AI.

Everything else was planned by me, it took me so much iterations from using switch-case in every method to make use of enum, then solving decoupling issues. I used AI just for writing fix methods due to lack of knowledge.

Hi, it's fine that you learnt what AI does when you use it without full understanding (issue with >95% PRs we see these days) - and thanks for being honest about it. Please be more careful next time, we are all here to answer questions.

Also, review AI code very well before using. Even if you didn't have idea about fields, the hardcoding of pages "1-10" in updateField(message, StandardField.PAGES, "1-10"); should have given you a hint that something is out of place (I am guessing that's what @koppor was referring to).

Edit: this was answer to your question in #12495 (comment):

Please tell me about the confusion, I am not clear about it.
I created this method because this code was being used in every method for updating fields.

@priyanshu16095 priyanshu16095 marked this pull request as draft March 20, 2025 01:52
entryTypes.remove(entry);
}

public void fix(IntegrityIssue issue, IntegrityMessage message) {
Copy link

Choose a reason for hiding this comment

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

Method lacks JavaDoc despite being a public method with non-trivial functionality (handling integrity issues). Complex operations should be documented.

Copy link

trag-bot bot commented Mar 21, 2025

@trag-bot didn't find any issues in the code! ✅✨

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

Successfully merging this pull request may close these issues.

integrity check and follow up actions
4 participants