-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Quality check escaped ampersand #9758
Quality check escaped ampersand #9758
Conversation
Please have a look at the checkstlye issues. Just go to the Files changes tab and reviewdog will show you the offending issues |
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.
Just a note: Although this should work both ways, translations should normally only be done with crowdin. Unified and tested common workflows lead to less errors.
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.
Yep, Crowdin will overwrite the non english translations on the next update
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.
Thank you for the information. We will make sure to do it the proper way next time.
593323b
to
83d6aab
Compare
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.
can you please add a changelog something like
" We added a new Integrity check for unscaped ampersands "
Okay, done :) |
Please merge the latest main into it (I just fixed an issue related from another pr) so that the unit tests are green again |
…deybis17/jabref into quality-check-escaped-ampersand
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.
Thank you for the PR! The implementation covered more cases than I thought of. Nice and clean test cases.
Neverthless, I have some nitpicks regarding the tests.
assertEquals(expected, checker.check(entry)); | ||
} | ||
|
||
private static Stream<Arguments> provideAcceptedInputs() { |
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.
You can rename that method to acceptsAllowedInputs
and remove the parameter at @MethodSource
assertEquals(List.of(new IntegrityMessage(expectedMessage, entry, field)), checker.check(entry)); | ||
} | ||
|
||
private static Stream<Arguments> provideUnacceptedInputs() { |
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.
Similar to above: rename to rejectsDisallowedInputs
and change @MethodSource("...")
to @MethodSource
return Stream.of( | ||
Arguments.of("Found 1 unescaped '&'", StandardField.SUBTITLE, "A single &"), | ||
Arguments.of("Found 2 unescaped '&'", StandardField.ABSTRACT, "Multiple \\\\& not properly & escaped"), | ||
Arguments.of("Found 1 unescaped '&'", StandardField.AUTHOR, "To many backslashes \\\\&"), |
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.
Small typo:
Arguments.of("Found 1 unescaped '&'", StandardField.AUTHOR, "To many backslashes \\\\&"), | |
Arguments.of("Found 1 unescaped '&'", StandardField.AUTHOR, "Too many backslashes \\\\&"), |
void entryWithEscapedAndUnescapedAmpersand() { | ||
entry.setField(StandardField.TITLE, "Jack \\& Jill & more"); | ||
assertEquals(List.of(new IntegrityMessage("Found 1 unescaped '&'", entry, StandardField.TITLE)), checker.check(entry)); | ||
} |
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.
Can you integrate that in rejectsDisallowedInputs
? I think, there is no additional logic here in this test case.
@Test | ||
void entryWithMultipleEscapedAndUnescapedAmpersands() { | ||
entry.setField(StandardField.AFTERWORD, "May the force be with you & live long \\\\& prosper \\& to infinity \\\\\\& beyond & assemble \\\\\\\\& excelsior!"); | ||
assertEquals(List.of(new IntegrityMessage("Found 4 unescaped '&'", entry, StandardField.AFTERWORD)), checker.check(entry)); | ||
} | ||
} |
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.
Can you integrate that in rejectsDisallowedInputs
? I think, there is no additional logic here in this test case.
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.
Sure, we can do that. The reasoning behind having it separated was that it basically combined the test cases from before, containing both escaped and unescaped ampersands (in the parametrized tests there was no mixing of the two).
@Siedlerchr already merged the PR. Maybe, you can do a follow-up PR @deybis17? |
Thank you for the feedback, and thanks @Siedlerchr for merging our PR! :-) We are happy to implement the requested changes, may we include them in the next PR (which is going to address the related cleanup action for ampersands) or should we make the changes in a separate PR? |
No, it's fine if you include this in your follow up PR! |
This refs #8712. |
Fixes for #8948
Fixes JabRef#585
Compulsory checks