sonyxperiadev / gerrit-events

MIT License
47 stars 62 forks source link

Filter out duplicate LineComments #82

Closed Vynce closed 5 years ago

Vynce commented 6 years ago

Exact duplicate LineComments don't make sense, so add an equals() method to the LineComment class that compares the line number and message and change CommentedFile to store a Set of unique LineComments instead of a List. A new CommentedFile(String fileName) constructor can be used to create an empty CommentedFile object which can then be populated using the addLineComment() method.

I also removed the unused Comments class and updated the minimum Java version to 7 to use the Objects.equals() method. I can rework LineComment.equals() if maintaining Java 6 support really is necessary.

Vynce commented 6 years ago

Thanks for taking a look! Those are both good points and I've removed the Java 7 change and added the Comments class back in this commit.

I can't find any use of the Comments class in gerrit-events or gerrit-trigger, but I suppose there may be other users of it. Let me know if you'd like me to replace its List<LineComment> with Set<LineComment>, similar to ReviewInput, or mark it as deprecated or anything -- either way it doesn't have any impact on my use case.

Vynce commented 6 years ago

@rsandell, ping :smile:

Vynce commented 5 years ago

@rsandell, could you please take another look at this change when you get a chance?

rsandell commented 5 years ago

Sorry for the delay, have a lot of other things on my plate atm.

Vynce commented 5 years ago

Thanks! No worries :smile: