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

[#4591] Add Integrity check for books with edition reported as 1 #4642

Merged
merged 3 commits into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/main/java/org/jabref/logic/integrity/EditionChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class EditionChecker implements ValueChecker {
private static final Predicate<String> FIRST_LETTER_CAPITALIZED = Pattern.compile("^[A-Z]").asPredicate();
private static final Predicate<String> ONLY_NUMERALS_OR_LITERALS = Pattern.compile("^([0-9]+|[^0-9].+)$")
.asPredicate();
private static final String FIRST_EDITION = "1";

private final BibDatabaseContext bibDatabaseContextEdition;

Expand Down Expand Up @@ -44,10 +45,15 @@ public Optional<String> checkValue(String value) {
}

//BibTeX
if (!bibDatabaseContextEdition.isBiblatexMode() && !FIRST_LETTER_CAPITALIZED.test(value.trim())) {
if (!bibDatabaseContextEdition.isBiblatexMode() && !FIRST_LETTER_CAPITALIZED.test(value.trim()) &&
!value.equals(FIRST_EDITION)) {
return Optional.of(Localization.lang("should have the first letter capitalized"));
}

if (value.equals(FIRST_EDITION)) {
Copy link
Member

Choose a reason for hiding this comment

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

Personally, I would move this check before the biblatex/bibtex checks (then you don't need to modify the conditions of these if statements).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tobiasdiez yes, it makes more sense. Updated PR.

return Optional.of(Localization.lang("edition of book reported as just 1"));
}

return Optional.empty();
}
}
1 change: 1 addition & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1986,6 +1986,7 @@ Sumatra\ Reader=Sumatra Reader
shared=shared
should\ contain\ an\ integer\ or\ a\ literal=should contain an integer or a literal
should\ have\ the\ first\ letter\ capitalized=should have the first letter capitalized
edition\ of\ book\ reported\ as\ just\ 1=edition of book reported as just 1
Tools=Tools
What\'s\ new\ in\ this\ version?=What\'s new in this version?
Want\ to\ help?=Want to help?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ void testEditionChecks() {
withMode(createContext("edition", "Third, revised and expanded edition"), BibDatabaseMode.BIBLATEX));
assertCorrect(withMode(createContext("edition", "Edition 2000"), BibDatabaseMode.BIBLATEX));
assertWrong(withMode(createContext("edition", "2nd"), BibDatabaseMode.BIBLATEX));
assertWrong(createContext("edition", "1"));
}

@Test
Expand Down