Skip to content

Refactor PagesChecker: Extract duplicate regex constants#14567

Merged
koppor merged 9 commits into
JabRef:mainfrom
Zeglow:refactor-pages-clean
Dec 11, 2025
Merged

Refactor PagesChecker: Extract duplicate regex constants#14567
koppor merged 9 commits into
JabRef:mainfrom
Zeglow:refactor-pages-clean

Conversation

@Zeglow

@Zeglow Zeglow commented Dec 10, 2025

Copy link
Copy Markdown
Contributor

Closes #14562

Refactors PagesChecker by extracting duplicated regex patterns for page numbers and separators into named constants (e.g., SINGLE_PAGE_PATTERN).

Steps to test

Please run the tests:

  • PagesCheckerBibtexTest
  • PagesCheckerBiblatexTest

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • [/] I added screenshots in the PR description (if change is visible to the user)
  • [/] I described the change in CHANGELOG.md in a way that is understandable for the average user (if change is visible to the user)
  • I checked the user 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 updating file(s) in https://github.com/JabRef/user-documentation/tree/main/en.

@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Dec 10, 2025
Comment on lines +20 to +36
"\\A" // begin String
+ SINGLE_PAGE_PATTERN
+ "("
+ "(\\+|-{2}|\u2013)" // separator, must contain exactly two dashes
+ "[A-Za-z]?\\d*" // optional prefix and number
+ BIBTEX_RANGE_SEPARATOR
+ SINGLE_PAGE_PATTERN
+ ")?"
+ "\\z"; // end String
+ "\\z"; // end String

// See https://packages.oth-regensburg.de/ctan/macros/latex/contrib/biblatex/doc/biblatex.pdf#subsubsection.3.15.3 for valid content
private static final String PAGES_EXP_BIBLATEX =
"\\A" // begin String
+ "[A-Za-z]?\\d*" // optional prefix and number
"\\A" // begin String
+ SINGLE_PAGE_PATTERN
+ "("
+ "(\\+|-{1,2}|\u2013)" // separator
+ "[A-Za-z]?\\d*" // optional prefix and number
+ BIBLATEX_RANGE_SEPARATOR
+ SINGLE_PAGE_PATTERN
+ ")?"
+ "\\z"; // end String
+ "\\z"; // end String

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comments dont align on indentation. Please fix

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the feedback.

@koppor koppor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR is causing effort on our team.

WE DO NOT HAVE ENDLESS TIME.

Please respect our time.

Please try to spend more thoughts on the PRs.

Comment on lines -16 to -21
+ "[A-Za-z]?\\d*" // optional prefix and number
"\\A" // begin String
+ SINGLE_PAGE_PATTERN
+ "("
+ "(\\+|-{2}|\u2013)" // separator, must contain exactly two dashes
+ "[A-Za-z]?\\d*" // optional prefix and number
+ BIBTEX_RANGE_SEPARATOR
+ SINGLE_PAGE_PATTERN
+ ")?"
+ "\\z"; // end String

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comments ARE NOT KEPT. Comments are deleted.

Refactoring is not about just making the code nicer. IT IS ABOUT KEEPING CODE COMMENTS - meaning: KEEPING THE GUIDANCE FOR DEVELOPERS.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the feedback! I totally understand, and sorry for the inconvenience. I have restored the comments as requested. However, I noticed that some unrelated files might have been included during the sync with the upstream branch. I still need some time to figure it out.

@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Dec 10, 2025
Comment on lines +14 to +20
// optional prefix and number
private static final String SINGLE_PAGE_PATTERN = "[A-Za-z]?\\d*";

// separator, must contain exactly two dashes
private static final String BIBTEX_RANGE_SEPARATOR = "(\\+|-{2}|\u2013)";
// separator
private static final String BIBLATEX_RANGE_SEPARATOR = "(\\+|-{1,2}|\u2013)";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you see why the formatting is consistent?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the feedback and your patience!

I realize I was lacking awareness of the formatting conventions. I was uncertain about the comment placement, and after checking other files in the codebase, I noticed some used above-line comments, which is why I went with that style.

I've now updated the formatting. If there are any other issues, please feel free to point them out.

Thank you for your time!

@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Dec 10, 2025
@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Dec 11, 2025

@koppor koppor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Even though the comments on line 19 and 25 are not well algined, I approve to be able to focus on other PRs.

Thank you for your time.

@koppor koppor added this pull request to the merge queue Dec 11, 2025
Merged via the queue into JabRef:main with commit 7e1ddc6 Dec 11, 2025
49 checks passed
shubhamk0205 pushed a commit to shubhamk0205/jabref that referenced this pull request Dec 11, 2025
* Refactor PagesChecker: Extract duplicate regex constants

Fixes JabRef#14562

* fix comments dont align on indentation

* Restore regex comments

* Revert "Merge branch 'refactor-pages-clean' of https://github.com/Zeglow/jabref into clean-fix"

This reverts commit 788979c, reversing
changes made to a4a0236.

* Revert "Restore regex comments"

This reverts commit a4a0236.

* restore MainTablePreferences.java, JabRefGuiPreferences.java and PagesChecker.java

* fix comment formatting issue
Siva-Sai22 pushed a commit to Siva-Sai22/jabref that referenced this pull request Dec 19, 2025
* Refactor PagesChecker: Extract duplicate regex constants

Fixes JabRef#14562

* fix comments dont align on indentation

* Restore regex comments

* Revert "Merge branch 'refactor-pages-clean' of https://github.com/Zeglow/jabref into clean-fix"

This reverts commit 788979c, reversing
changes made to a4a0236.

* Revert "Restore regex comments"

This reverts commit a4a0236.

* restore MainTablePreferences.java, JabRefGuiPreferences.java and PagesChecker.java

* fix comment formatting issue
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.

Refactor PagesChecker: Extract duplicate regex constants

3 participants