-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat:Allowed multiple delimiter in keyword separator field. #13706
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
base: main
Are you sure you want to change the base?
Conversation
The approach seems to be wrong. Do test-driven development. Add tests for each fetcher. At least for the one mentioned in the issue. You can do heuristics. On the fetcher side. Not on the keywords class. |
can you give me some example for the tests and where is this fetcher located. |
|
It's in the |
Your pull request conflicts with the target branch. Please merge |
@@ -481,7 +481,15 @@ public static String getFieldValue(BibEntry entry, String pattern, Character key | |||
} else if (pattern.matches("keyword\\d+")) { | |||
// according to LabelPattern.php, it returns keyword number n | |||
int num = Integer.parseInt(pattern.substring(7)); | |||
KeywordList separatedKeywords = entry.getResolvedKeywords(keywordDelimiter, database); | |||
// KeywordList separatedKeywords = entry.getResolvedKeywords(keywordDelimiter, database); |
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.
Commented code should be removed as it serves no purpose in understanding the current implementation and clutters the codebase. Git history should be used to track changes.
@@ -481,7 +481,15 @@ public static String getFieldValue(BibEntry entry, String pattern, Character key | |||
} else if (pattern.matches("keyword\\d+")) { | |||
// according to LabelPattern.php, it returns keyword number n | |||
int num = Integer.parseInt(pattern.substring(7)); | |||
KeywordList separatedKeywords = entry.getResolvedKeywords(keywordDelimiter, database); | |||
// KeywordList separatedKeywords = entry.getResolvedKeywords(keywordDelimiter, database); |
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.
Another instance of commented code that should be removed. Version control systems like Git are designed to maintain code history, making commented-out code unnecessary.
Thanks for your interest in jabref. If you want to push around a list of multiple delimiters, use a list. Keep the level of abstraction. Maybe one wants du use "./." As a delimiter? Also please add tests / use test driven development as @koppor suggests. |
actually I am facing difficulty in that . |
KeywordListTest.java |
This reverts commit 88fe7f7.
First, I was not sure if this OK - however, the KeywordList can have different parsing modes. Maybe with a heuristics to find out the keyword seperator - then this list can be serialized again and put into the BibEntry returned by the fetcher. |
Note that your PR will not be reviewed/accepted until you have gone through the mandatory checks in the description and marked each of them them exactly in the format of |
@@ -73,6 +94,10 @@ public static KeywordList parse(String keywordString, Character delimiter) { | |||
return parse(keywordString, delimiter, Keyword.DEFAULT_HIERARCHICAL_DELIMITER); | |||
} | |||
|
|||
public static KeywordList parseMultipleDelimeter(String keywordString, String delimiter) { |
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.
Method name contains a spelling error ('Delimeter' instead of 'Delimiter'), which violates consistent and correct naming conventions in the codebase.
for (char d:delimiter.toCharArray()) { | ||
keywordString = keywordString.replace(d, ','); | ||
} |
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.
String mutation in loop is inefficient. Using StringBuilder or StringJoiner would be more performant for string manipulations.
@Test | ||
void parseMultipleDelimiter() { | ||
assertEquals(new KeywordList("keywordOne", "keywordTwo", "keywordThree"), | ||
KeywordList.parseMultipleDelimeter("keywordOne; keywordTwo: keywordThree", ";:")); |
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.
Method name contains a typo ('Delimeter' instead of 'Delimiter'), which violates the requirement for correctly spelled variable and method names.
Closes #12974
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)