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

Introduce Flux and Stream Refaster rules to suggest filtering before sorting #393

Merged
merged 5 commits into from
Dec 9, 2022
Merged

Introduce Flux and Stream Refaster rules to suggest filtering before sorting #393

merged 5 commits into from
Dec 9, 2022

Conversation

CoolTomatos
Copy link
Contributor

Closes #386.

@github-actions
Copy link

github-actions bot commented Dec 6, 2022

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

4 similar comments
@github-actions
Copy link

github-actions bot commented Dec 6, 2022

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

github-actions bot commented Dec 6, 2022

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

github-actions bot commented Dec 6, 2022

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

github-actions bot commented Dec 7, 2022

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie rickie self-requested a review December 7, 2022 17:59
@rickie rickie added this to the 0.7.0 milestone Dec 7, 2022
@Stephan202
Copy link
Member

Stephan202 commented Dec 7, 2022

Rebased to test whether I can push to the fork, which worked ✔️ Adding the PR to my review list :)

@github-actions
Copy link

github-actions bot commented Dec 7, 2022

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link
Member

@Stephan202 Stephan202 left a comment

Choose a reason for hiding this comment

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

Added a commit. Nice work! I think we should move some methods around, but need to leave the train now 😄

@@ -167,6 +167,34 @@ Stream<R> after(Stream<T> stream, Function<? super S, ? extends Stream<? extends
}
}

/** Apply filtering before sorting to reduce the number of elements to sort. */
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps slightly more idiomatic:

Suggested change
/** Apply filtering before sorting to reduce the number of elements to sort. */
/** Filter before sorting to reduce the number of elements to sort. */

Copy link
Member

Choose a reason for hiding this comment

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

Alternatively:

Suggested change
/** Apply filtering before sorting to reduce the number of elements to sort. */
/** Apply {@link Stream#filter(Predicate)} before {@link Stream#sorted()} to reduce the number of elements to sort. */

In most cases we do reference the relevant methods, so let's go with this one.

@@ -167,6 +167,34 @@ Stream<R> after(Stream<T> stream, Function<? super S, ? extends Stream<? extends
}
}

/** Apply filtering before sorting to reduce the number of elements to sort. */
static final class SortAfterFilter<T> {
Copy link
Member

Choose a reason for hiding this comment

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

(We still have to automate this, but) our current naming scheme would dictate that this class is named StreamFilterSorted.


Stream<Integer> testSortWithComparatorAfterFilter() {
return Stream.of(1, 4, 3, 2)
.sorted(Comparator.comparingInt(Integer::intValue).reversed())
Copy link
Member

Choose a reason for hiding this comment

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

If we use reverseOrder() we can simplify elidedTypesAndStaticImports above.

@github-actions
Copy link

github-actions bot commented Dec 7, 2022

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

1 similar comment
@github-actions
Copy link

github-actions bot commented Dec 8, 2022

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link
Member

@Stephan202 Stephan202 left a comment

Choose a reason for hiding this comment

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

Added one more commit. Very nice contribution @CoolTomatos!

Suggested commit message:

Introduce `Flux` and `Stream` Refaster rules to suggest filtering before sorting (#393)

Fixes #386.

@@ -1246,4 +1247,36 @@ Duration after(StepVerifier.LastStep step, Duration duration) {
return step.verifyTimeout(duration);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Right now we have the StepVerifier-related rules at the bottom; let's keep that.

@github-actions
Copy link

github-actions bot commented Dec 8, 2022

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link
Member

@rickie rickie left a comment

Choose a reason for hiding this comment

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

Rebased and added a commit.

Changes LGTM!

Made one tweak to the suggested commit message to be more inline with the previous commit messages (IMO).

Thanks for opening a PR Sir @CoolTomatos 😉!

* Apply {@link Flux#filter(Predicate)} before {@link Flux#sort()} to reduce the number of
* elements to sort.
*/
static final class StreamFilterSort<T> {
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a small copy / paste error from the actual StreamRules. This should be FluxFilterSort, likewise for the WithComparator one :).

@rickie rickie modified the milestones: 0.7.0, 0.6.0 Dec 8, 2022
@github-actions
Copy link

github-actions bot commented Dec 8, 2022

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie
Copy link
Member

rickie commented Dec 9, 2022

Rebased, will merge once 💚.

@github-actions
Copy link

github-actions bot commented Dec 9, 2022

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie rickie changed the title Refaster rules that encourage filtering before sorting. Introduce Flux and Stream Refaster rules to suggest filtering before sorting Dec 9, 2022
@rickie rickie merged commit 17bcdb6 into PicnicSupermarket:master Dec 9, 2022
@CoolTomatos CoolTomatos deleted the filtering_before_sorting branch December 9, 2022 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Refaster rules that encourage filtering before sorting
3 participants