RFR: 1256: Use stream api to simplify the csr issue lookup [v3]

Guoxiong Li gli at openjdk.java.net
Wed Dec 1 16:39:14 UTC 2021

On Wed, 1 Dec 2021 13:38:25 GMT, Magnus Ihse Bursie <ihse at openjdk.org> wrote:

>> Guoxiong Li has updated the pull request incrementally with one additional commit since the last revision:
>>   Improve the encapsulation and use the methods of the 'Optional' instead of direct null check
> bots/csr/src/main/java/org/openjdk/skara/bots/csr/CSRBot.java line 85:
>> 83:             var csrOptional = jbsIssue.get().links().stream()
>> 84:                     .filter(link -> link.relationship().isPresent() && "csr for".equals(link.relationship().get()))
>> 85:                     .findAny().flatMap(Link::issue);
> I realize you'd be breaking abstractions by using csrLink() from CSRCommand, but maybe you can create a duplicated csrLink method here? I think it would help with readability, at least. And if we ever refactor this more, it would be a clear candidate to move to a class that is accessible from both here and CSRCommand.

Encapsulating such a method can be reused in the future. Fixed

> bots/pr/src/main/java/org/openjdk/skara/bots/pr/CheckRun.java line 139:
>> 137:             return Optional.empty();
>> 138:         }
>> 139:         var csr = jbsIssue.get().links().stream()
> ... and here as well. It's really unfortunate that we have no good framework for where to place such common functionality. :-(



PR: https://git.openjdk.java.net/skara/pull/1248

More information about the skara-dev mailing list