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

Check for different editions in the duplicate check #2991

Merged
merged 3 commits into from
Jul 10, 2017

Conversation

LinusDietz
Copy link
Member

Fixes #2960 by checking for different editions before the actual duplicate check.
If both BibEntries have a Edition field that mismatches, it cannot be a duplicate.

  • Change in CHANGELOG.md described
  • Tests created for changes

@LinusDietz LinusDietz added type: enhancement integrity-checker status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Jul 10, 2017
private static boolean hasSameIdentifier(BibEntry one, BibEntry two) {
private static boolean haveDifferentEditions(BibEntry one, BibEntry two) {
if (one.getField(FieldName.EDITION).isPresent() && two.getField(FieldName.EDITION).isPresent()) {
if (!one.getField(FieldName.EDITION).get().equals(two.getField(FieldName.EDITION).get())) {
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 direclty compare Optionals with equals, but be aware that two empty optionals also equal.
https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#equals-java.lang.Object-

Copy link
Member Author

@LinusDietz LinusDietz Jul 10, 2017

Choose a reason for hiding this comment

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

Yeah, I'm aware of that. That's why I first checked both to be present, and then called .get() on both to explicitly state that this line will only work if there is a value in the Optionals.

Copy link
Member

Choose a reason for hiding this comment

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

Okay, good! Then it's fine

@@ -26,7 +26,7 @@
* This class contains utility method for duplicate checking of entries.
*/
public class DuplicateCheck {
public static double duplicateThreshold = 0.75; // The overall threshold to signal a duplicate pair
private static final double duplicateThreshold = 0.75; // The overall threshold to signal a duplicate pair
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 very minor thing, the constant variable should be uppercase

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.

see the optional stuff

@LinusDietz LinusDietz merged commit e80f450 into master Jul 10, 2017
@LinusDietz LinusDietz deleted the non-duplicate-editions branch July 10, 2017 15:36
Siedlerchr added a commit that referenced this pull request Jul 11, 2017
* upstream/master:
  Eclipse J
  Add switch indentation for Eclipse and add some new missing formatting options
  Check for different editions in the duplicate check (#2991)
  Add CheckStyle Check for Constants (final static) (#2992)
  Add Remove link context menu entry in file editor (#2972)
  Fix DiVA tests
  Remove <pre> tag from entries fetched using MathSciNet (#2990)
  Fix Brazilian Portugese language loading (#2981)
  Use sftp's symlink command to provide symlink to latest version
  Update gradle from 4.0 to 4.0.1
  Fix group storage (#2978)
  Fix keybindings in entry editor (#2971)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrity-checker status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers type: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants