Skip to content

Quality check escaped ampersand#9758

Merged
Siedlerchr merged 11 commits into
JabRef:mainfrom
deybis17:quality-check-escaped-ampersand
Apr 15, 2023
Merged

Quality check escaped ampersand#9758
Siedlerchr merged 11 commits into
JabRef:mainfrom
deybis17:quality-check-escaped-ampersand

Conversation

@deybis17

@deybis17 deybis17 commented Apr 12, 2023

Copy link
Copy Markdown
Contributor

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
- [x] Change in `CHANGELOG.md` described in a way that is understandable for the average user (if applicable)
- [x] Tests created for changes (if applicable)
- [x] Manually tested changed features in running JabRef (always required)
- [ ] Screenshots added in PR description (for UI changes)
- [ ] [Checked developer's documentation](https://devdocs.jabref.org/): Is the information available and up to date? If not, I outlined it in this pull request.
- [ ] [Checked documentation](https://docs.jabref.org/): 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 to the documentation repository.

@Siedlerchr

Copy link
Copy Markdown
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
Copy Markdown
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.

@Siedlerchr Siedlerchr Apr 13, 2023

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.

Yep, Crowdin will overwrite the non english translations on the next update

Copy link
Copy Markdown
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

@Siedlerchr Siedlerchr 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.

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

Zylence commented Apr 15, 2023

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

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

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

koppor commented Apr 15, 2023

Copy link
Copy Markdown
Member

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

@Zylence

Zylence commented Apr 17, 2023

Copy link
Copy Markdown
Contributor

@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
Copy Markdown
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

koppor commented Apr 24, 2023

Copy link
Copy Markdown
Member

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