Refactor PagesChecker: Extract duplicate regex constants#14567
Conversation
| "\\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 |
There was a problem hiding this comment.
Comments dont align on indentation. Please fix
There was a problem hiding this comment.
Thank you for the feedback.
koppor
left a comment
There was a problem hiding this comment.
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.
| + "[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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
…low/jabref into clean-fix" This reverts commit 788979c, reversing changes made to a4a0236.
This reverts commit a4a0236.
| // 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)"; |
There was a problem hiding this comment.
Do you see why the formatting is consistent?
There was a problem hiding this comment.
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!
koppor
left a comment
There was a problem hiding this comment.
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.
* 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
* 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
Closes #14562
Refactors
PagesCheckerby extracting duplicated regex patterns for page numbers and separators into named constants (e.g., SINGLE_PAGE_PATTERN).Steps to test
Please run the tests:
Mandatory checks
CHANGELOG.mdin a way that is understandable for the average user (if change is visible to the user)