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

Quality check escaped ampersand #9758

Merged
merged 11 commits into from
Apr 15, 2023

Conversation

deybis17
Copy link
Contributor

@deybis17 deybis17 commented Apr 12, 2023

Fixes for #8948
Fixes JabRef#585

  • Unscaped ampersands can be found and displayed on the check integrity window
  • Tests added for escaped ampersand

Compulsory checks

Preview Give feedback

@Siedlerchr
Copy link
Member

Please have a look at the checkstlye issues. Just go to the Files changes tab and reviewdog will show you the offending issues

Copy link
Member

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.

Copy link
Member

@Siedlerchr Siedlerchr Apr 13, 2023

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

Copy link
Contributor

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.

@Zylence Zylence force-pushed the quality-check-escaped-ampersand branch from 593323b to 83d6aab Compare April 14, 2023 15:01
Siedlerchr
Siedlerchr previously approved these changes Apr 15, 2023
Copy link
Member

@Siedlerchr Siedlerchr left a 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 "

@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Apr 15, 2023
@Zylence
Copy link
Contributor

Zylence commented Apr 15, 2023

can you please add a changelog something like " We added a new Integrity check for unscaped ampersands "

Okay, done :)

@Siedlerchr Siedlerchr marked this pull request as ready for review April 15, 2023 20:16
@Siedlerchr
Copy link
Member

Please merge the latest main into it (I just fixed an issue related from another pr) so that the unit tests are green again

@Siedlerchr Siedlerchr merged commit b0ac603 into JabRef:main Apr 15, 2023
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.

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() {
Copy link
Member

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() {
Copy link
Member

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 \\\\&"),
Copy link
Member

Choose a reason for hiding this comment

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

Small typo:

Suggested change
Arguments.of("Found 1 unescaped '&'", StandardField.AUTHOR, "To many backslashes \\\\&"),
Arguments.of("Found 1 unescaped '&'", StandardField.AUTHOR, "Too many backslashes \\\\&"),

Comment on lines +58 to +61
void entryWithEscapedAndUnescapedAmpersand() {
entry.setField(StandardField.TITLE, "Jack \\& Jill & more");
assertEquals(List.of(new IntegrityMessage("Found 1 unescaped '&'", entry, StandardField.TITLE)), checker.check(entry));
}
Copy link
Member

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.

Comment on lines +63 to +68
@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));
}
}
Copy link
Member

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.

Copy link
Contributor

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).

@koppor koppor removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Apr 15, 2023
@koppor
Copy link
Member

koppor commented Apr 15, 2023

@Siedlerchr already merged the PR. Maybe, you can do a follow-up PR @deybis17?

@Zylence
Copy link
Contributor

Zylence commented Apr 17, 2023

@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?

@Siedlerchr
Copy link
Member

No, it's fine if you include this in your follow up PR!
We have to thank your for your great work! Looking forward to the cleanup action :)

@koppor
Copy link
Member

koppor commented Apr 24, 2023

This refs #8712.

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.

New quality check and cleanup for &
5 participants